Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
migrate Mocha's tests to Unexpected assertion library (#3343)
* convert tests to use Unexpected as assertion library

Squashed commits:
[fc418f8] remove extra call to done() in test/unit/runnable.spec.js
[f1bc24f] lint test/browser-specific/setup.js
[48af58c] fix test flake in ESM test
[346ab5c] convert bundle and browser-specific tests to unexpected
[c76b2f4] fix typo in test/README.md [ci skip]
[783f16a] add test/README.md [ci skip]
[a5949bb] convert all "only" tests to unexpected
[15c921e] lint test/integration/diffs.spec.js
[0d7635e] convert all individual reporter tests to unexpectedalso don't eat `STDOUT`--this means the tests have more output--could be
useful for debugging.
[190f5ed] convert compiler tests to unexpected
[822b115] fix test/integration/glob.spec.js
[db4853d] fix jsapi test
[6f9831d] remove debugs from test/integration/diffs.spec.js
[4cfbe4f] remove useless manual browser tests that will never get used properly
[4e1d97b] convert test/reporters/base.spec.js to unexpected- add `chai` as dependency for `chai`-specific test, since the old one
was based on what we thought it should be, not what it actually is.
- improve test output: stop eating `STDOUT` and use color where possible
[a8378f9] convert test/node-unit/color.spec.js to unexpected
[92f50de] convert test/integration/reporters.spec.js to unexpected
[652a331] remove global assert
[ec857ef] convert test/integration/diffs.spec.js to unexpectedthis required a bit of massaging, since I had to change the
fixture to use `assert`, which produces slightly different output.also move `getDiffs()` out of `test/integration/helpers.js`,
since it's only used in `test/integration/diffs.spec.js`.
[436e85d] remove userland assert moduleit's safe to use the built-in assert module.
[dd7aec7] remove expect.js & karma-expect; add karma-unexpected
[01dff70] lint test/setup.js
[77203bf] convert test/integration/regression.spec.js to unexpected
[e9eb05e] add more assertions; fix others
[241159e] convert test/require/require.spec.js to unexpected
[eb6bcff] convert test/integration/options.spec.js to unexpected
[ada86aa] add custom assertions
[5368ebe] convert test/integration/no-diff.spec.js to unexpected
[043cfe3] convert test/integration/glob.spec.js to unexpected
[df748a3] convert test/integration/compiler-globbing.spec.js to unexpected
[5c0a8d0] convert test/interfaces/tdd.spec.js to unexpected
[c6622a6] convert test/interfaces/qunit.spec.js to unexpected
[1ecd62f] convert test/interfaces/exports.spec.js to unexpected
[cabda05] convert test/interfaces/bdd.spec.js to unexpected
[454018b] convert test/node-unit/stack-trace-filter.spec.js to unexpected
[be6c332] fix unhelpful error thrown from lookupFiles; convert test/node-unit/file-utils.spec.js to unexpected
[419d3ed] convert test/unit/grep.spec.js to unexpected
[4837a6a] convert test/unit/hook-sync-nested.spec.js to unexpected
[6d6b632] convert test/unit/hook-async.spec.js to unexpected
[6ec01eb] convert test/unit/hook-sync.spec.js to unexpected
[d4f6515] convert test/unit/ms.spec.js to unexpected
[c43c096] convert test/unit/mocha.spec.js to unexpected
[7aa9b82] convert test/unit/root.spec.js to unexpected
[13a9e24] convert test/unit/runnable.spec.js to unexpected
[cf9b376] convert test/unit/runner.spec.js to unexpected
[efe37f9] simplify exception tests in test/unit/suite.spec.js
[c08ba9e] convert test/unit/suite.spec.js to unexpected
[41a85d9] convert test/unit/test.spec.js to unexpected
[19f2d44] convert test/unit/throw.spec.js to unexpected
[70ec725] convert test/unit/context.spec.js to unexpected
[8c6cefd] convert test/unit/utils.spec.js to unexpected
[a626278] add unexpected
* fix missing assertion in an "options" integration test
* convert new test in options.spec.js to unexpected
* combine Chai test into a single assertion; increase timeout for reporter tests

Signed-off-by: Christopher Hiller <boneskull@boneskull.com>
  • Loading branch information
boneskull committed May 18, 2018
1 parent fae9af2 commit fb5393b
Show file tree
Hide file tree
Showing 83 changed files with 2,527 additions and 1,952 deletions.
1 change: 0 additions & 1 deletion .eslintrc.yml
Expand Up @@ -33,7 +33,6 @@ overrides:
mocha: yes
globals:
expect: no
assert: no
- files:
- doc/**/*.js
env:
Expand Down
2 changes: 1 addition & 1 deletion .wallaby.js
Expand Up @@ -3,7 +3,7 @@
module.exports = () => {
return {
files: [
'index.js', 'lib/**/*.js', 'test/setup.js',
'index.js', 'lib/**/*.js', 'test/setup.js', 'test/assertions.js',
{
pattern: 'test/node-unit/**/*.fixture.js',
instrument: false
Expand Down
12 changes: 9 additions & 3 deletions karma.conf.js
Expand Up @@ -16,7 +16,7 @@ const browserPlatformPairs = {
module.exports = config => {
let bundleDirpath;
const cfg = {
frameworks: ['browserify', 'expect', 'mocha'],
frameworks: ['browserify', 'mocha'],
files: [
// we use the BDD interface for all of the tests that
// aren't interface-specific.
Expand Down Expand Up @@ -141,8 +141,8 @@ module.exports = config => {
// support
cfg.browsers = ['ChromeHeadless'];
cfg.files = [
'test/browser-fixtures/esm.fixture.html',
'test/browser-specific/esm.spec.js'
'test/browser-specific/esm.spec.js',
'test/browser-fixtures/esm.fixture.html'
];
break;
default:
Expand All @@ -151,6 +151,12 @@ module.exports = config => {
}
}

cfg.files.unshift(
'node_modules/unexpected/unexpected.js',
{pattern: 'node_modules/unexpected/unexpected.js.map', included: false},
'test/browser-specific/setup.js'
);

config.set(cfg);
};

Expand Down
5 changes: 5 additions & 0 deletions lib/utils.js
Expand Up @@ -546,6 +546,11 @@ exports.lookupFiles = function lookupFiles(filepath, extensions, recursive) {
// ignore error
return;
}
if (!extensions) {
throw new Error(
'extensions parameter required when filepath is a directory'
);
}
var re = new RegExp('\\.(?:' + extensions.join('|') + ')$');
if (!stat.isFile() || !re.test(file) || path.basename(file)[0] === '.') {
return;
Expand Down

0 comments on commit fb5393b

Please sign in to comment.