-
Notifications
You must be signed in to change notification settings - Fork 23
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
Fix test performance #169
Fix test performance #169
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vojtechszocs The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@@ -12,8 +10,13 @@ const config: InitialOptionsTsJest = { | |||
|
|||
collectCoverage: true, | |||
coverageDirectory: 'coverage', | |||
coverageReporters: ['json', 'lcov', 'text'], | |||
coverageReporters: ['lcov'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may eventually need the other reporters, but I think this is fine for now.
"test-print-config": "jest --showConfig", | ||
"test-e2e": "yarn workspace @monorepo/e2e-sample-app run test-e2e", | ||
"test-e2e-open": "yarn workspace @monorepo/e2e-sample-app run test-e2e-open", | ||
"test-e2e-ci": "start-server-and-test 'yarn run-samples' '9000|9001' 'yarn test-e2e'", | ||
"eslint": "eslint --max-warnings 0 --ext .js,.jsx,.ts,.tsx", | ||
"eslint-print-config": "eslint --print-config", | ||
"jest": "TZ=UTC jest", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's generally better to set env. variables when calling scripts, rather than inside scripts or programs.
Side note, patternfly-react
also sets the timezone this way, see here.
/hold |
Some more updates incoming. |
7925c66
to
3b19a89
Compare
/hold cancel |
@@ -5,7 +5,7 @@ const config: InitialOptionsTsJest = { | |||
preset: 'ts-jest/presets/js-with-ts', | |||
|
|||
testMatch: ['**/*.test.(js|jsx|ts|tsx)'], | |||
transformIgnorePatterns: ['/node_modules/(?!(@patternfly)/)'], | |||
transformIgnorePatterns: ['/node_modules/'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI this was one of the reasons of the slowdowns, since we instructed ts-jest
to transform all PatternFly packages by default.
/retest |
@vojtechszocs: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/lgtm |
optimize test config for better performance (*)
maxWorkers
to1
when in CI environmentisolatedModules
totrue
regardless of the environmentkeep using Jest
27.x
but updatetesting-library
dependencies@testing-library/react
must be12.x
because we're using React17.x
@testing-library/dom
was removed since it's pulled in via@testing-library/jest-dom
remove
import '@testing-library/jest-dom'
in test filespackages/common/test-configs/setup-react.ts
update
collectCoverageFrom
to exclude tests and Storybook storiesAccording to kulshekhar/ts-jest#259 (comment) Jest workers run independently from each other, therefore each worker runs TypeScript compilation on its own, which results in slower times (due to multiple parallel TS compiler executions) which are offset by workers running in parallel.
Local testing via
rm -rf /tmp/jest_rs ; yarn test
shows that running all tests (includes code coverage collection) withisolatedModules: true
is ~3.5 times faster. Since we don't really need full type checking when running tests (already covered by our "build" scripts which fail upon any TS type errors), it makes sense to always useisolatedModules: true
.