Skip to content

Commit 352af62

Browse files
chore(auth-providers): switch to vitest (mostly) (redwoodjs#9869)
This PR updates the auth providers with the exception of two: 1. `@redwoodjs/auth-firebase-web` It contains jest specific code for specifically resolving uuid to CJS. I'm sure it's possible to switch it over but I have not yet tried. 3. `@redwoodjs/auth-dbauth-web` I encountered errors that WebAuthn was not supported within the test environment. Even with the `jsdom` environment set.
1 parent 68ed27a commit 352af62

90 files changed

Lines changed: 515 additions & 576 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/auth-providers/auth0/api/jest.config.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

packages/auth-providers/auth0/api/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"build:types": "tsc --build --verbose",
2020
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
2121
"prepublishOnly": "NODE_ENV=production yarn build",
22-
"test": "jest src",
23-
"test:watch": "yarn test --watch"
22+
"test": "vitest run src",
23+
"test:watch": "vitest watch src"
2424
},
2525
"dependencies": {
2626
"@babel/runtime-corejs3": "7.23.6",
@@ -33,8 +33,8 @@
3333
"@babel/core": "^7.22.20",
3434
"@redwoodjs/api": "6.0.7",
3535
"@types/jsonwebtoken": "9.0.5",
36-
"jest": "29.7.0",
37-
"typescript": "5.3.3"
36+
"typescript": "5.3.3",
37+
"vitest": "1.2.1"
3838
},
3939
"gitHead": "3905ed045508b861b495f8d5630d76c7a157d8f1"
4040
}

packages/auth-providers/auth0/api/src/__tests__/auth0.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import jwt from 'jsonwebtoken'
2+
import { vi, test, expect } from 'vitest'
23

34
import { verifyAuth0Token } from '../decoder'
45

5-
jest.mock('jsonwebtoken', () => ({
6-
verify: jest.fn(),
7-
decode: jest.fn(),
6+
vi.mock('jsonwebtoken', () => ({
7+
default: {
8+
verify: vi.fn(),
9+
decode: vi.fn(),
10+
},
811
}))
912

1013
test('verify, and not decode, should be called in production', () => {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineConfig, configDefaults } from 'vitest/config'
2+
3+
export default defineConfig({
4+
test: {
5+
exclude: [...configDefaults.exclude, '**/fixtures'],
6+
},
7+
})

packages/auth-providers/auth0/setup/jest.config.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

packages/auth-providers/auth0/setup/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"build:types": "tsc --build --verbose",
2020
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
2121
"prepublishOnly": "NODE_ENV=production yarn build",
22-
"test": "jest src",
23-
"test:watch": "yarn test --watch"
22+
"test": "vitest run src",
23+
"test:watch": "vitest watch src"
2424
},
2525
"dependencies": {
2626
"@babel/runtime-corejs3": "7.23.6",
@@ -31,8 +31,8 @@
3131
"@babel/cli": "7.23.4",
3232
"@babel/core": "^7.22.20",
3333
"@types/yargs": "17.0.32",
34-
"jest": "29.7.0",
35-
"typescript": "5.3.3"
34+
"typescript": "5.3.3",
35+
"vitest": "1.2.1"
3636
},
3737
"gitHead": "3905ed045508b861b495f8d5630d76c7a157d8f1"
3838
}

packages/auth-providers/auth0/setup/src/__tests__/setup.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import { vi, test, expect } from 'vitest'
2+
13
import { command, description, builder, handler } from '../setup'
24

35
// mock Telemetry for CLI commands so they don't try to spawn a process
4-
jest.mock('@redwoodjs/telemetry', () => {
6+
vi.mock('@redwoodjs/telemetry', () => {
57
return {
68
errorTelemetry: () => jest.fn(),
79
timedTelemetry: () => jest.fn(),
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineConfig, configDefaults } from 'vitest/config'
2+
3+
export default defineConfig({
4+
test: {
5+
exclude: [...configDefaults.exclude, '**/fixtures'],
6+
},
7+
})

packages/auth-providers/auth0/web/jest.config.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/auth-providers/auth0/web/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"build:types": "tsc --build --verbose",
2020
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
2121
"prepublishOnly": "NODE_ENV=production yarn build",
22-
"test": "jest src",
23-
"test:watch": "yarn test --watch"
22+
"test": "vitest run src",
23+
"test:watch": "vitest watch src"
2424
},
2525
"dependencies": {
2626
"@babel/runtime-corejs3": "7.23.6",
@@ -32,9 +32,9 @@
3232
"@babel/cli": "7.23.4",
3333
"@babel/core": "^7.22.20",
3434
"@types/react": "18.2.37",
35-
"jest": "29.7.0",
3635
"react": "0.0.0-experimental-e5205658f-20230913",
37-
"typescript": "5.3.3"
36+
"typescript": "5.3.3",
37+
"vitest": "1.2.1"
3838
},
3939
"peerDependencies": {
4040
"@auth0/auth0-spa-js": "2.1.2"

0 commit comments

Comments
 (0)