-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: migrate from Jest to Vitest (#2495)
* Go all-in with Jest ESM migration * Migrate from Jest to Vitest
- Loading branch information
Showing
258 changed files
with
1,163 additions
and
1,731 deletions.
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
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 |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
"bootstrap": "lerna bootstrap", | ||
"prepublish": "lerna run build", | ||
"lint": "eslint packages", | ||
"test": "NODE_OPTIONS=\"--experimental-vm-modules\" jest", | ||
"test": "vitest", | ||
"dev": "lerna run dev --scope @react-pdf/examples", | ||
"changeset": "changeset", | ||
"version-packages": "changeset version", | ||
|
@@ -34,32 +34,29 @@ | |
"@babel/preset-react": "^7.18.6", | ||
"@changesets/changelog-github": "^0.4.8", | ||
"@changesets/cli": "^2.26.0", | ||
"@jest/globals": "^29.5.0", | ||
"@rollup/plugin-alias": "^3.1.8", | ||
"@rollup/plugin-babel": "^5.3.0", | ||
"@rollup/plugin-commonjs": "^21.0.1", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-node-resolve": "^13.0.6", | ||
"@rollup/plugin-replace": "^3.0.0", | ||
"@testing-library/react": "^14.0.0", | ||
"@vitejs/plugin-react": "^4.2.1", | ||
"babel-eslint": "^10.0.1", | ||
"babel-jest": "^29.5.0", | ||
"babel-plugin-add-module-exports": "^1.0.0", | ||
"canvas": "^2.11.0", | ||
"chalk": "^2.4.2", | ||
"eslint": "^6.8.0", | ||
"eslint-config-airbnb": "^18.1.0", | ||
"eslint-config-prettier": "^4.0.0", | ||
"eslint-plugin-import": "^2.20.2", | ||
"eslint-plugin-jest": "^22.3.0", | ||
"eslint-plugin-jsx-a11y": "^6.2.3", | ||
"eslint-plugin-promise": "^4.0.1", | ||
"eslint-plugin-react": "^7.20.0", | ||
"eslint-plugin-react-hooks": "^2.5.1", | ||
"husky": "^7.0.4", | ||
"jest": "^29.5.0", | ||
"jest-environment-jsdom": "^29.5.0", | ||
"jest-image-snapshot": "^6.1.0", | ||
"jsdom": "^23.2.0", | ||
"lerna": "^8.0.2", | ||
"lint-staged": "^10.5.4", | ||
"pdfjs-dist": "3.2.146", | ||
|
@@ -73,7 +70,9 @@ | |
"rollup-plugin-local-resolve": "^1.0.7", | ||
"rollup-plugin-polyfill-node": "^0.9.0", | ||
"rollup-plugin-sourcemaps": "^0.6.3", | ||
"rollup-plugin-terser": "^7.0.2" | ||
"rollup-plugin-terser": "^7.0.2", | ||
"vitest": "^1.2.0", | ||
"vitest-fetch-mock": "^0.2.2" | ||
}, | ||
"lint-staged": { | ||
"*.js": [ | ||
|
@@ -86,6 +85,5 @@ | |
"url": "https://opencollective.com/react-pdf", | ||
"logo": "https://opencollective.com/opencollective/logo.txt" | ||
}, | ||
"dependencies": {}, | ||
"packageManager": "[email protected]" | ||
} |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { describe, expect, test } from 'vitest'; | ||
|
||
import adjust from '../src/adjust'; | ||
|
||
const add = v => v + 1; | ||
|
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
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { describe, expect, test } from 'vitest'; | ||
|
||
import get from '../src/get'; | ||
|
||
describe('get', () => { | ||
|
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,5 @@ | ||
/* eslint-disable no-void */ | ||
import { describe, expect, test } from 'vitest'; | ||
|
||
import isNil from '../src/isNil'; | ||
|
||
|
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,3 +1,5 @@ | ||
import { describe, expect, test } from 'vitest'; | ||
|
||
import last from '../src/last'; | ||
|
||
describe('last', () => { | ||
|
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { describe, expect, test } from 'vitest'; | ||
|
||
import omit from '../src/omit'; | ||
|
||
describe('omit', () => { | ||
|
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,3 +1,5 @@ | ||
import { describe, expect, test } from 'vitest'; | ||
|
||
import pick from '../src/pick'; | ||
|
||
describe('pick', () => { | ||
|
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 |
---|---|---|
@@ -1,15 +1,12 @@ | ||
/* eslint-disable */ | ||
import { jest } from '@jest/globals'; | ||
import { createRequire } from 'module'; | ||
import { vi } from 'vitest'; | ||
import createFetchMock from 'vitest-fetch-mock'; | ||
|
||
import '../../polyfills'; | ||
|
||
const require = createRequire(import.meta.url); | ||
const fetchMocker = createFetchMock(vi); | ||
fetchMocker.enableMocks(); | ||
|
||
global.BROWSER = false; | ||
|
||
const customGlobal = global; | ||
customGlobal.fetch = require('jest-fetch-mock'); | ||
customGlobal.fetchMock = customGlobal.fetch; | ||
|
||
jest.setMock('cross-fetch', fetch); | ||
vi.mock('cross-fetch', () => ({ default: global.fetch })); |
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
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
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,11 @@ | ||
// false positive on import/no-unresolved | ||
// eslint-disable-next-line import/no-unresolved | ||
import { defineConfig } from 'vitest/config'; | ||
|
||
export default defineConfig({ | ||
test: { | ||
setupFiles: ['vitest.setup.js'], | ||
include: ['tests/*.{test,spec}.?(c|m)[jt]s?(x)'], | ||
watch: false, | ||
}, | ||
}); |
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 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import { vi } from 'vitest'; | ||
import createFetchMock from 'vitest-fetch-mock'; | ||
|
||
const fetchMocker = createFetchMock(vi); | ||
fetchMocker.enableMocks(); | ||
|
||
global.BROWSER = false; | ||
|
||
vi.mock('cross-fetch', () => ({ default: global.fetch })); |
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 |
---|---|---|
@@ -1,14 +1,12 @@ | ||
/* eslint-disable */ | ||
import { createRequire } from 'module'; | ||
import { vi } from 'vitest'; | ||
import createFetchMock from 'vitest-fetch-mock'; | ||
|
||
import '../../polyfills'; | ||
|
||
const require = createRequire(import.meta.url); | ||
const fetchMocker = createFetchMock(vi); | ||
fetchMocker.enableMocks(); | ||
|
||
global.BROWSER = false; | ||
|
||
const customGlobal = global; | ||
customGlobal.fetch = require('jest-fetch-mock'); | ||
customGlobal.fetchMock = customGlobal.fetch; | ||
|
||
jest.setMock('cross-fetch', fetch); | ||
vi.mock('cross-fetch', () => ({ default: global.fetch })); |
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
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
Oops, something went wrong.