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

test: add test script to each component's package.json file #687

Merged
merged 4 commits into from
Aug 13, 2021

Conversation

mediremi
Copy link
Contributor

@mediremi mediremi commented Aug 9, 2021

Adds a test script to each component's package.json file, allowing us to run yarn test for individual components.

Also adds jest enzyme config for components whose tests use enzyme.

@mediremi mediremi requested a review from varl August 9, 2021 14:01
@cypress
Copy link

cypress bot commented Aug 9, 2021



Test summary

512 0 0 0


Run details

Project ui
Status Passed
Commit 007fb9b
Started Aug 12, 2021 3:19 PM
Ended Aug 12, 2021 3:31 PM
Duration 11:39 💡
OS Linux Ubuntu - 20.04
Browser Electron 89

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

Copy link
Contributor

@varl varl left a comment

Choose a reason for hiding this comment

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

Nice.

Would have been nifty if we could have passed in e.g. d2-app-scripts test --jest-config ../../jest.config.js and re-used the Jest and Enzyme configuration (the --config flag is taken). That can be a future thing.

@mediremi
Copy link
Contributor Author

I've implemented the jestConfig option here: dhis2/app-platform#605

Unfortunately we can't reuse the top level jest.config.js for running individual components' tests due to the roots config and the fact that the current working directory in the config file will be the component directory so we'll need this additional config in a file called something like jest.shared.config.js:

module.exports = {
    setupFilesAfterEnv: [`${__dirname}/jest.enzyme.config.js`],
    testPathIgnorePatterns: [
        '/node_modules/',
        '/build/',
        '/.d2/',
    ],
}

I'm happy to update this PR once dhis2/app-platform#605 is merged.

@mediremi mediremi requested a review from varl August 12, 2021 15:05
@@ -0,0 +1,4 @@
module.exports = {
setupFilesAfterEnv: [`${__dirname}/jest.enzyme.config.js`],
Copy link
Contributor

Choose a reason for hiding this comment

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

Neato !

@mediremi mediremi enabled auto-merge (squash) August 13, 2021 08:15
@mediremi mediremi merged commit a0c360b into master Aug 13, 2021
@mediremi mediremi deleted the fix/test-script branch August 13, 2021 08:27
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 6.16.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@varl varl mentioned this pull request Sep 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants