Skip to content

Commit

Permalink
rewire qunit es module globally
Browse files Browse the repository at this point in the history
  • Loading branch information
izelnakri committed Jan 21, 2021
1 parent f59eb51 commit abe2124
Show file tree
Hide file tree
Showing 5 changed files with 1,568 additions and 13 deletions.
3 changes: 1 addition & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ process.title = 'qunitx';
if (entry.isDirectory()) {
console.log('entry', entry, ' is directory');
} else if (entry.isFile()) { // what to do when its .ts
global.window = global;

const QUnit = (await import('./lib/setup-node-js-environment.js')).default;

console.log(fileOrFolder);
await import(`${process.cwd()}/${fileOrFolder}`);

QUnit.start();
Expand Down
6 changes: 4 additions & 2 deletions lib/commands/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ ${highlight("Input options:")}
- File: $ ${color('qunitx test/foo.js')}
- Folder: $ ${color('qunitx test/login')}
- Glob: $ ${color('qunitx test/**/*.ts')}
- Regex: $ ${color('qunit \w+-test.ts')}
- Combination: $ ${color('qunit test/foo.js test/bar.js test/logout app/e2e/submit-\w+.ts')}
- Regex: $ ${color('qunitx \w+-test.ts')}
- Combination: $ ${color('qunitx test/foo.js test/bar.js test/logout app/e2e/submit-\w+.ts')}
${highlight("Optional flags:")}
${color('--browser')} : run qunit tests in chromium with puppeteer instead of node.js(which is the default)
Expand All @@ -29,5 +29,7 @@ ${color('--reporter')} : define a reporter
${color('--coverage')} : define a coverage dist folder target(by default ./dist)
${highlight("Example:")} $ ${color('qunitx test/foo.ts#204 app/e2e --browser --debug --watch')}
To create a new qunitx file do: $ ${color('qunitx new myNewTest')}
`);
}
4 changes: 3 additions & 1 deletion lib/setup-node-js-environment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import chalk from 'chalk';
import QUnit from 'qunit';
import QUnit from '../index.js';

global.window = global;

window.QUnit = QUnit;
window.QUNIX_TEST_TIME_COUNTER = (function() { // NOTE: might be needed for failFast option timeTaken calculation
Expand Down
Loading

0 comments on commit abe2124

Please sign in to comment.