-
Notifications
You must be signed in to change notification settings - Fork 7
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(image-utils): replace jest
with vitest
#5711
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fee16e5
test(image-utils): replace `jest` with `vitest`
eventualbuddha b90c841
test(image-utils): replace `jest` API with `vitest` API
eventualbuddha 0d98fa2
chore: re-sync pnpm lockfile
eventualbuddha 26da6ac
make `test/arbitraries` a module and exclude `.mts` from build
eventualbuddha 9311f8c
remove outdated jest config
eventualbuddha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
bin | ||
build | ||
coverage | ||
jest.config.js | ||
vitest.config.mts |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,9 +14,9 @@ | |
"lint": "pnpm type-check && eslint .", | ||
"lint:fix": "pnpm type-check && eslint . --fix", | ||
"test": "is-ci test:ci test:watch", | ||
"test:ci": "jest --coverage --ci --reporters=default --reporters=jest-junit --maxWorkers=6", | ||
"test:coverage": "jest --coverage", | ||
"test:watch": "jest --watch" | ||
"test:ci": "vitest run --coverage", | ||
"test:coverage": "vitest --coverage", | ||
"test:watch": "vitest" | ||
}, | ||
"packageManager": "[email protected]", | ||
"dependencies": { | ||
|
@@ -32,23 +32,19 @@ | |
"tmp": "^0.2.1" | ||
}, | ||
"devDependencies": { | ||
"@jest/types": "^29.6.1", | ||
"@types/debug": "4.1.8", | ||
"@types/jest": "^29.5.3", | ||
"@types/jest-image-snapshot": "^6.4.0", | ||
"@types/node": "20.16.0", | ||
"@types/pdfjs-dist": "2.1.3", | ||
"@types/pixelmatch": "^5.2.6", | ||
"@types/tmp": "0.2.4", | ||
"@vitest/coverage-istanbul": "^2.1.8", | ||
"esbuild": "0.21.2", | ||
"esbuild-runner": "2.2.2", | ||
"eslint-plugin-vx": "workspace:*", | ||
"fast-check": "2.23.2", | ||
"is-ci-cli": "2.2.0", | ||
"jest": "^29.6.2", | ||
"jest-junit": "^16.0.0", | ||
"jest-watch-typeahead": "^2.2.2", | ||
"lint-staged": "11.0.0", | ||
"ts-jest": "29.1.1" | ||
"vitest": "^2.1.8" | ||
} | ||
} |
9 changes: 5 additions & 4 deletions
9
libs/image-utils/src/crop.test.ts → libs/image-utils/src/crop.test.mts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
.../image-utils/src/jest_match_image.test.ts → ...image-utils/src/jest_match_image.test.mts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
libs/image-utils/src/numeric.test.ts → libs/image-utils/src/numeric.test.mts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
libs/image-utils/test/arbitraries.test.ts → libs/image-utils/test/arbitraries.test.mts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { defineConfig } from '../../vitest.config.shared.mjs'; | ||
|
||
export default defineConfig({ | ||
test: { | ||
setupFiles: ['test/setupTests.ts'], | ||
coverage: { | ||
exclude: ['src/jest_pdf_snapshot.ts', 'src/cli/pdf_to_images.ts'], | ||
}, | ||
}, | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
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.
Why are the imports changed to have an extension? And why are the files changed to
.mts
?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 changed
test-utils-vitest
to usetype: module
inpackage.json
because the files would be transpiled to CommonJS and we'd get arequire('vitest')
in the resulting build. Here is the file you get if yourequire('vitest')
:So now
test-utils-vitest/build/index.js
is ESM. If you then depend ontest-utils-vitest
and try to import it in a CJS test file, you get this:Since I don't want to change the packages themselves to be ESM yet, I change the test files to be treated as ESM by renaming them to
.mts
. This makes everything work out. Once we're using ESM, though, we need to import relative files including their target extension. So we add the.js
extension to the imports from the.mts
files.