Skip to content

Instantly share code, notes, and snippets.

@joakin
Created May 8, 2018 09:21
Show Gist options
  • Save joakin/c2235e92812ac2e442dd325742aab6ea to your computer and use it in GitHub Desktop.
Save joakin/c2235e92812ac2e442dd325742aab6ea to your computer and use it in GitHub Desktop.
Running a qunit test that requires a non-existent file
qunit-cli-bug => ls
node_modules package.json test.js yarn.lock
qunit-cli-bug => jq .scripts package.json
{
"test": "qunit test.js"
}
qunit-cli-bug => cat test.js
const test = require("./index.js");
QUnit.module("Test");
QUnit.test(
"This test should fail because index.js can't be required",
assert => {
assert.equal(test(), 1);
}
);
qunit-cli-bug => yarn test
yarn run v1.6.0
(node:86768) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
$ qunit test.js
TAP version 13
not ok 1 test.js > Failed to load the test file with error:
Error: Cannot find module './index.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:571:15)
at Function.Module._load (internal/modules/cjs/loader.js:497:25)
at Module.require (internal/modules/cjs/loader.js:626:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/Users/jhernandez/dev/tests/qunit-cli-bug/test.js:1:76)
at Module._compile (internal/modules/cjs/loader.js:678:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
at Module.load (internal/modules/cjs/loader.js:589:32)
at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
at Function.Module._load (internal/modules/cjs/loader.js:520:3)
---
message: "should be able to load file"
severity: failed
actual: false
expected: true
stack: at Object.<anonymous> (/Users/jhernandez/dev/tests/qunit-cli-bug/node_modules/qunit/bin/run.js:61:13)
...
1..1
# pass 0
# skip 0
# todo 0
# fail 1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment