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

Replace mocha.opts file with .mocharc.json configuration file #1052

Open
myang5 opened this issue Dec 10, 2020 · 1 comment
Open

Replace mocha.opts file with .mocharc.json configuration file #1052

myang5 opened this issue Dec 10, 2020 · 1 comment

Comments

@myang5
Copy link

myang5 commented Dec 10, 2020

Is your feature request related to a problem? Please describe.
This is related to a bug I ran into! The current challenges rely on a mocha.opts file to specify mocha flags. However, this method of specifying options has been deprecated, which prevents me from running tests (specified in Additional context section).

Describe the solution you'd like
I was able to create a .mocharc.json configuration file based on the docs that fixes the issue and allows the tests to run, so it would probably help to replace the mocha.opts file with that.

challenges/address-book/.mocharc.json:

{
  "require": ["ts-node/register", "source-map-support/register"],
  "timeout": 60000,
  "extension": ["js", "ts", "json"],
  "spec": "test/**/*.test.ts"
}

Describe alternatives you've considered
The mocha version in the package.json could use semver to specify an older version that allows for the mocha.opts file, but replacing the configuration file to keep up with newer mocha versions seems more reasonable.

Additional context
This is the error I initially got when I ran yarn test in the challenges/address-book folder:

$ yarn test
yarn run v1.22.5
$ mocha
Error: No test files found
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I then tried to edit the test script in the package.json from just "mocha" to "mocha --opts test/mocha.opts" because I thought it would work with the older mocha version, but I still got an error:

× ERROR: --opts: configuring Mocha via 'mocha.opts' is DEPRECATED and no longer supported.
          Please use a configuration file instead.
error Command failed with exit code 1.

After this I made the configuration file.

@CodeSchwert
Copy link

+1 for this, I had to setup the same config to get the mocha tests to work.

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

2 participants