Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to directly run some tests with Mocha #8308

Closed
stieg opened this issue Nov 6, 2019 · 1 comment
Closed

Unable to directly run some tests with Mocha #8308

stieg opened this issue Nov 6, 2019 · 1 comment
Labels
developer-experience This issue improves error messages, debugging, or reporting
Milestone

Comments

@stieg
Copy link
Contributor

stieg commented Nov 6, 2019

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
Should be able to run test files directly. It turns out that we can not do this for all files.

If the current behavior is a bug, please provide the steps to reproduce.

$ npx mocha --exit test/utils.test.js
/home/stieg/Devel/airfordable/mongoose/lib/types/buffer.js:7
const Binary = require('../driver').get().Binary;
                                         ^

TypeError: Cannot read property 'Binary' of null
    at Object.<anonymous> (/home/stieg/Devel/airfordable/mongoose/lib/types/buffer.js:7:42)
    at Module._compile (internal/modules/cjs/loader.js:936:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
    at Module.load (internal/modules/cjs/loader.js:790:32)
    at Function.Module._load (internal/modules/cjs/loader.js:703:12)
    at Module.require (internal/modules/cjs/loader.js:830:19)
    at require (internal/modules/cjs/helpers.js:68:18)
    at Object.<anonymous> (/home/stieg/Devel/airfordable/mongoose/test/utils.test.js:8:24)
    at Module._compile (internal/modules/cjs/loader.js:936:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
    at Module.load (internal/modules/cjs/loader.js:790:32)
    at Function.Module._load (internal/modules/cjs/loader.js:703:12)
    at Module.require (internal/modules/cjs/loader.js:830:19)
    at require (internal/modules/cjs/helpers.js:68:18)
    at /home/stieg/Devel/airfordable/mongoose/node_modules/mocha/lib/mocha.js:250:27
    at Array.forEach (<anonymous>)
    at Mocha.loadFiles (/home/stieg/Devel/airfordable/mongoose/node_modules/mocha/lib/mocha.js:247:14)
    at Mocha.run (/home/stieg/Devel/airfordable/mongoose/node_modules/mocha/lib/mocha.js:576:10)
    at Object.<anonymous> (/home/stieg/Devel/airfordable/mongoose/node_modules/mocha/bin/_mocha:637:18)
    at Module._compile (internal/modules/cjs/loader.js:936:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
    at Module.load (internal/modules/cjs/loader.js:790:32)
    at Function.Module._load (internal/modules/cjs/loader.js:703:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)
    at internal/main/run_main_module.js:17:11

What is the expected behavior?*
This should work so we can expedite testing.

Issue is that the driver is not set when run directly, but is set when when you run the npm test target. Based on the value of the target nothing special is being set so this is likely a run order bug.

@stieg stieg changed the title Unable to directly run some tests with Mocah Unable to directly run some tests with Mocha Nov 6, 2019
@vkarpov15 vkarpov15 added this to the 5.7.10 milestone Nov 9, 2019
@vkarpov15 vkarpov15 added the developer-experience This issue improves error messages, debugging, or reporting label Nov 9, 2019
@vkarpov15
Copy link
Collaborator

That's a good idea, fixed. We generally just use npm test -- -g so never ran into this issue before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
developer-experience This issue improves error messages, debugging, or reporting
Projects
None yet
Development

No branches or pull requests

2 participants