fix(tests): Make .mocharc.js independent of current working directory#7329
Merged
cpcallen merged 1 commit intoRaspberryPiFoundation:developfrom Jul 31, 2023
Merged
fix(tests): Make .mocharc.js independent of current working directory#7329cpcallen merged 1 commit intoRaspberryPiFoundation:developfrom
.mocharc.js independent of current working directory#7329cpcallen merged 1 commit intoRaspberryPiFoundation:developfrom
Conversation
Move tests/browser/test/.mocharc.js to tests/browser and use __dirname to make the require directive work regardless of where mocha is invoked from. Simplify the browser:test script accordingly, taking advantage also of the mocha default of running all tests in the test/ subdirectory.
| "tsc": "gulp tsc", | ||
| "test": "gulp test", | ||
| "test:browser": "npx mocha ./tests/browser/test --config ./tests/browser/test/.mocharc.js", | ||
| "test:browser": "cd tests/browser && npx mocha", |
Collaborator
There was a problem hiding this comment.
Consider adding && cd .. to get back to the original directory after running the command.
rachel-fenichel
approved these changes
Jul 27, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The basics
npm run formatandnpm run lintThe details
Resolves
Fixes difficulties with running individual tests via
npx mocha path/to/test_file.jsProposed Changes
Move
tests/browser/test/.mocharc.jstotests/browserand use__dirnameto make therequiredirective work regardless of wheremochais invoked from.Simplify the
browser:testscript accordingly, taking advantage also of the mocha default of running all tests in thetest/subdirectory.Behaviour Before Change
It was necessary to be in the repository root, and specify
--config tests/browser/test/.mocharc.jsin order to successfully invokemochaon any/all of the files intests/browser/test.Behaviour After Change
The previous way works, but it's also possible to
npx mocha path/to/test_file.jsfrom anywhere inbrowser/tests/Reason for Changes
Convenience when developing tests.
Test Coverage
Unchanged.