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

New deprecation warning with --compilers #16

Closed
zelliott opened this issue Nov 2, 2017 · 4 comments
Closed

New deprecation warning with --compilers #16

zelliott opened this issue Nov 2, 2017 · 4 comments

Comments

@zelliott
Copy link

zelliott commented Nov 2, 2017

According to the latest version of mocha, runnig the --compilers flag results in the error:

(node:14392) DeprecationWarning: "--compilers" will be removed in a future version of Mocha; see https://git.io/vdcSr for more info

In attempting to change my test runner command from:

--compilers ts:ts-node/register
--require tsconfig-paths/register ...

to

--require ts-node/register tsconfig-paths/register

the following warnings/errors are thrown:

Warning: Could not find any test files matching pattern: tsconfig-paths/register
Error: Cannot find module [my-imported-library]

There probably needs to be a fix for this when the compilers tag is turned off for good.

@joseSantacruz
Copy link

Same issue here, I also tried to change to:

--require ts-node/register
--require tsconfig-paths/register

But I get the error:
No test files found
I also tried to change to:

--require tsconfig-paths/register
--require ts-node/register

But then I get the error:

/usr/src/app/node_modules/ts-node/src/index.ts:425
  const result = loadSync(cwd, typeof project === 'string' ? project : undefined)
                 ^
TypeError: tsconfig_1.loadSync is not a function
    at readConfig (/usr/src/app/node_modules/ts-node/src/index.ts:425:18)
    at Object.register (/usr/src/app/node_modules/ts-node/src/index.ts:189:18)
    at Object.<anonymous> (/usr/src/app/node_modules/ts-node/register.js:1:15)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at /usr/src/app/node_modules/mocha/bin/_mocha:370:3
    at Array.forEach (native)
    at Object.<anonymous> (/usr/src/app/node_modules/mocha/bin/_mocha:369:10)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:390:7)
    at startup (bootstrap_node.js:150:9)
    at bootstrap_node.js:505:3

@Jontem
Copy link
Collaborator

Jontem commented Nov 3, 2017

According to Mocha compiler deprecation

Mocha, by default, loads only .js when given a directory (and the default directory is test). Therefore, to use a different file extension (such as .coffee or .ts), you will need to supply a glob instead of simply a directory.

This works for me:
mocha -r ts-node/register -r tsconfig-paths/register "test/**/*.ts"

@joseSantacruz
Copy link

thank you, @Jontem adding the extension part works

@zelliott
Copy link
Author

zelliott commented Nov 3, 2017

Yep, thanks @Jontem. Closing this bug.

@zelliott zelliott closed this as completed Nov 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants