-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Yarn scripts for quality of life in development #5087
Yarn scripts for quality of life in development #5087
Conversation
…ion testing) in development Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
…is able to be specific to a file Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
@@ -28,6 +28,8 @@ | |||
"build:mac": "yarn run compile && electron-builder --mac --dir", | |||
"build:win": "yarn run compile && electron-builder --win --dir", | |||
"integration": "jest --runInBand --detectOpenHandles --forceExit integration", | |||
"test:unit": "jest --watch --testPathIgnorePatterns integration", |
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 discovered you need to make sure you have an up-to-date build before running this
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.
Yes, this is intentional. The script is for development, and for that, it is optimized for quick start-up.
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.
ok, bit messy if it's already running when you checkout a new branch
@@ -28,6 +28,8 @@ | |||
"build:mac": "yarn run compile && electron-builder --mac --dir", | |||
"build:win": "yarn run compile && electron-builder --win --dir", | |||
"integration": "jest --runInBand --detectOpenHandles --forceExit integration", | |||
"test:unit": "jest --watch --testPathIgnorePatterns integration", | |||
"test:integration": "func() { jest ${1:-xyz} --watch --runInBand --detectOpenHandles --forceExit --modulePaths=[\"<rootDir>/integration/\"]; }; func", |
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.
What file changes will cause tests to rerun? I edited/saved some files but no tests were run ("No tests found, exiting with code 0").
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.
For unit tests
, watch triggers after a change in most production or test code (and also some configuration files). The initial behavior of jest --watch
is to use git to find uncommitted production and test-code, and run all tests directly or indirectly affected by those changes.
In your case:
- The changed files need to be related to a test for anything to happen.
- Our current unrelated configuration expects
*.test
-files to contain at least one test in order to not be perceived as failure. This explains"No tests found, exiting with code 0"
.
Deviating from this, for integration tests
the watch triggers only for changes in test code, as the tests happen over already built application. Still, this makes tweaking the slow integration tests a bit more friendly :)
FYI: In watch mode, you can also use w
to see additional controls. Eg. p
or t
will make you able to specify explicitly which tests to run, a
will make you run all tests despite git, and f
will make you re-run only failing tests. Cool stuff, right? :)
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.
pretty sure I edited an integration test file (edited some string, maybe the test name). I'll try again
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 added a test to integration/__tests__/cluster-pages.tests.ts
and saved. No tests found. Pressing o
runs the tests. Is this how to use it?
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 could have a sesh? Or all this should be documented somewhere within jest. Hmm.
Run and watch targetable unit- or integration-tests.