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.
This adds the Jest testing framework to the project.
Adding tests
Copying the style of the React repository, tests can be added into
/src/__tests__/*.js
.Note
There was discussion of putting Jest tests into a folder named
__jest__
as a precaution against conflicts with a future testing framework. This PR does not do that. It follows Jest's defaults.Reasoning: If an additional, testing framework is added in the future and there is a naming conflict,
__tests__
can be renamed and thejest.config.js
testMatch
field can be updated to match. In the meantime, there's no reason to change the defaults.Writing tests
Tests can be written following the examples from the Jest documentation.
However, Ancient Beast's already-installed linter as well as the checks run on Github require that the Jest module values be imported explicitly, e.g.,
See
/src/__tests__/utility/string.js
for an example.Running tests
The test runner was added to the existing
npm run test
.In addition, the following commands were added to
package.json
:npm run jest
– Run testsnpm run start:jest
– Watch test files and rerun when modified