Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@aldeed
Copy link
Contributor

@aldeed aldeed commented Sep 12, 2019

Impact: minor
Type: test

Issue

Jest integration tests are slow

Solution

  • Switch to jest-mongodb package. It does the same thing we were already doing, setting up mongodb-memory-server, but it does it in a way that can happen one time total rather than one time per test file.
  • Run integration tests "in band" and with Jest cache, so that they can take advantage of the jest-mongodb package.

Running locally, integration tests are 8x faster for me.

Breaking changes

None

Testing

  • npm run test:integration and confirm it's faster
  • Confirm the integration test task on CircleCI is as fast or faster than before.

if (process.env.JEST_MONGO) {
delete jestConfig.testEnvironment;
jestConfig.preset = "@shelf/jest-mongodb";
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this file was auto-generated by Jest init. I moved our "jest" key from package.json into here and then added this conditional here to load the @shelf/jest-mongodb preset when JEST_MONGO env is set. The npm test scripts that need in-memory MongoDB running are updated with JEST_MONGO=1.

@aldeed aldeed self-assigned this Sep 12, 2019
@aldeed
Copy link
Contributor Author

aldeed commented Sep 16, 2019

@bt3gl Did you npm install first to install the new @shelf/jest-mongodb package?

because we have client unit tests

Signed-off-by: Eric Dobbertin <[email protected]>
@von-steinkirch
Copy link
Contributor

After running on containers, using:
docker-compose run --rm reaction npm install @shelf/jest-mongodb and then
docker-compose run --rm reaction npm run test:integration, all the tests passed. T
heir speed is absolutely improved!

🛳-it!

@von-steinkirch von-steinkirch merged commit c7566e2 into develop Sep 17, 2019
@von-steinkirch von-steinkirch deleted the feat-aldeed-jest-mongodb branch September 17, 2019 17:03
@kieckhafer kieckhafer mentioned this pull request Sep 18, 2019
@kieckhafer kieckhafer mentioned this pull request Sep 25, 2019
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

Successfully merging this pull request may close these issues.

3 participants