Skip to content

Commit ee3388c

Browse files
committed
reintroduce node golden generation
@asturur this is what I meant in the comments of #8206
1 parent 80a778a commit ee3388c

File tree

2 files changed

+43
-30
lines changed

2 files changed

+43
-30
lines changed

scripts/index.js

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -320,40 +320,53 @@ async function runTestem({ suite, port, launch, dev, processOptions, context } =
320320
* @returns {Promise<boolean | undefined>} true if some tests failed
321321
*/
322322
async function test(suite, tests, options = {}) {
323-
const processOptions = {
324-
cwd: wd,
325-
env: {
326-
...process.env,
327-
TEST_FILES: (tests || []).join(','),
328-
NODE_CMD: ['qunit', 'test/node_test_setup.js', 'test/lib'].concat(tests || `test/${suite}`).join(' '),
329-
VERBOSE: Number(options.verbose),
330-
QUNIT_DEBUG_VISUAL_TESTS: Number(options.debug),
331-
QUNIT_RECREATE_VISUAL_REFS: Number(options.recreate),
332-
QUNIT_FILTER: options.filter,
333-
REPORT_FILE: options.out
334-
},
335-
shell: true,
336-
stdio: 'inherit',
337-
}
338-
339323
let failed = false;
324+
const qunitEnv = {
325+
QUNIT_DEBUG_VISUAL_TESTS: Number(options.debug),
326+
QUNIT_RECREATE_VISUAL_REFS: Number(options.recreate),
327+
QUNIT_FILTER: options.filter,
328+
};
329+
const env = {
330+
...process.env,
331+
TEST_FILES: (tests || []).join(','),
332+
NODE_CMD: ['qunit', 'test/node_test_setup.js', 'test/lib'].concat(tests || `test/${suite}`).join(' '),
333+
VERBOSE: Number(options.verbose),
334+
REPORT_FILE: options.out
335+
};
336+
const browserContexts = options.context.filter(c => c !== 'node');
340337

341338
// temporary revert
342339
// run node tests directly with qunit
343340
if (options.context.includes('node')) {
344341
try {
345-
cp.execSync(processOptions.env.NODE_CMD, processOptions);
342+
cp.execSync(env.NODE_CMD, {
343+
cwd: wd,
344+
env: {
345+
...env,
346+
// browser takes precendence in golden ref generation
347+
...(browserContexts.length === 0 ? qunitEnv : {})
348+
},
349+
shell: true,
350+
stdio: 'inherit',
351+
});
346352
} catch (error) {
347353
failed = true;
348354
}
349355
}
350356

351-
const browserContexts = options.context.filter(c => c !== 'node');
352357
if (browserContexts.length > 0) {
353358
failed = await runTestem({
354359
...options,
355360
suite,
356-
processOptions,
361+
processOptions: {
362+
cwd: wd,
363+
env: {
364+
...env,
365+
...qunitEnv
366+
},
367+
shell: true,
368+
stdio: 'inherit',
369+
},
357370
context: browserContexts
358371
}) || failed;
359372
}

test/node_test_setup.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ var chalk = require('chalk');
33
var diff = require('deep-object-diff').diff;
44
var commander = require('commander');
55

6-
// commander.program
7-
// .option('-d, --debug', 'debug visual tests by overriding refs (golden images) in case of visual changes', false)
8-
// .option('-r, --recreate', 'recreate visual refs (golden images)', false)
9-
// .action(options => {
10-
// QUnit.debug = QUnit.debugVisual = options.debug;
11-
// QUnit.recreateVisualRefs = options.recreate;
12-
// }).parse(process.argv);
13-
// // for now accept an env variable because qunit doesn't allow passing unknown options
14-
// QUnit.debugVisual = Number(process.env.QUNIT_DEBUG_VISUAL_TESTS);
15-
// QUnit.recreateVisualRefs = Number(process.env.QUNIT_RECREATE_VISUAL_REFS);
16-
// QUnit.config.filter = process.env.QUNIT_FILTER;
6+
commander.program
7+
.option('-d, --debug', 'debug visual tests by overriding refs (golden images) in case of visual changes', false)
8+
.option('-r, --recreate', 'recreate visual refs (golden images)', false)
9+
.action(options => {
10+
QUnit.debug = QUnit.debugVisual = options.debug;
11+
QUnit.recreateVisualRefs = options.recreate;
12+
}).parse(process.argv);
13+
// for now accept an env variable because qunit doesn't allow passing unknown options
14+
QUnit.debugVisual = Number(process.env.QUNIT_DEBUG_VISUAL_TESTS);
15+
QUnit.recreateVisualRefs = Number(process.env.QUNIT_RECREATE_VISUAL_REFS);
16+
QUnit.config.filter = process.env.QUNIT_FILTER;
1717

1818
global.fabric = require('../dist/fabric').fabric;
1919
global.pixelmatch = require('pixelmatch');

0 commit comments

Comments
 (0)