Skip to content

Commit

Permalink
refactor: refactor before call
Browse files Browse the repository at this point in the history
  • Loading branch information
aadityataparia committed Jun 13, 2019
1 parent c7125c0 commit 64ef3a8
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 18 deletions.
11 changes: 6 additions & 5 deletions dist/sifrr.dev.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/sifrr.dev.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/sifrr.dev.min.js

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions dist/sifrr.dev.module.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/sifrr.dev.module.js.map

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions src/test/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,15 @@ async function runTests(options = {}) {
junitXmlFile = path.join(root, `./test-results/${path.basename(root)}/results.xml`),
inspect = false,
reporters = ['html'],
mochaOptions = {}
mochaOptions = {},
before
} = options;

if (inspect) require('inspector').open(undefined, undefined, true);

const beforeRet = typeof before === 'function' ? before() : false;
if (beforeRet instanceof Promise) await beforeRet;

const allFolders = deepMerge({
unitTest: path.join(root, './test/unit'),
browserTest: path.join(root, './test/browser'),
Expand Down Expand Up @@ -133,7 +137,7 @@ async function runTests(options = {}) {

if (global.__pdescribes) {
const fs = await Promise.all(global.__pdescribes);
failures += fs.reduce((a, b) => a + b);
failures += fs.reduce((a, b) => a + b, 0);
}

// Get and write code coverage
Expand All @@ -151,8 +155,6 @@ async function runTests(options = {}) {

process.on('message', async (options) => {
options = JsonFn.parse(options);
const before = typeof options.before === 'function' ? options.before() : false;
if (before instanceof Promise) await before;

await runTests(options).catch(f => {
if (Number(f)) process.send(`${f}`);
Expand Down
2 changes: 1 addition & 1 deletion src/test/testglobals.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function getCaller() {
}

module.exports = (mochaOptions) => {
global.__pdescribes = [Promise.resolve(0)];
global.__pdescribes = [];
global.ENV = process.env.NODE_ENV = process.env.NODE_ENV || 'test';
global.Mocha = require('mocha');
global.chai = require('chai');
Expand Down

0 comments on commit 64ef3a8

Please sign in to comment.