Skip to content
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

chore(auth-providers): switch to vitest (mostly) #9869

Merged
merged 9 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
auth0
  • Loading branch information
Josh-Walker-GM committed Jan 22, 2024
commit 7d9f704f1d53f1b42775c807abb36ae6533cc764
4 changes: 0 additions & 4 deletions packages/auth-providers/auth0/api/jest.config.js

This file was deleted.

8 changes: 4 additions & 4 deletions packages/auth-providers/auth0/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"build:types": "tsc --build --verbose",
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
"prepublishOnly": "NODE_ENV=production yarn build",
"test": "jest src",
"test:watch": "yarn test --watch"
"test": "vitest run src",
"test:watch": "vitest watch src"
},
"dependencies": {
"@babel/runtime-corejs3": "7.23.6",
Expand All @@ -33,8 +33,8 @@
"@babel/core": "^7.22.20",
"@redwoodjs/api": "6.0.7",
"@types/jsonwebtoken": "9.0.5",
"jest": "29.7.0",
"typescript": "5.3.3"
"typescript": "5.3.3",
"vitest": "1.2.1"
},
"gitHead": "3905ed045508b861b495f8d5630d76c7a157d8f1"
}
9 changes: 6 additions & 3 deletions packages/auth-providers/auth0/api/src/__tests__/auth0.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import jwt from 'jsonwebtoken'
import { vi, test, expect } from 'vitest'

import { verifyAuth0Token } from '../decoder'

jest.mock('jsonwebtoken', () => ({
verify: jest.fn(),
decode: jest.fn(),
vi.mock('jsonwebtoken', () => ({
default: {
verify: vi.fn(),
decode: vi.fn(),
},
}))

test('verify, and not decode, should be called in production', () => {
Expand Down
7 changes: 7 additions & 0 deletions packages/auth-providers/auth0/api/vitest.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig, configDefaults } from 'vitest/config'

export default defineConfig({
test: {
exclude: [...configDefaults.exclude, '**/fixtures'],
},
})
4 changes: 0 additions & 4 deletions packages/auth-providers/auth0/setup/jest.config.js

This file was deleted.

8 changes: 4 additions & 4 deletions packages/auth-providers/auth0/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"build:types": "tsc --build --verbose",
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
"prepublishOnly": "NODE_ENV=production yarn build",
"test": "jest src",
"test:watch": "yarn test --watch"
"test": "vitest run src",
"test:watch": "vitest watch src"
},
"dependencies": {
"@babel/runtime-corejs3": "7.23.6",
Expand All @@ -31,8 +31,8 @@
"@babel/cli": "7.23.4",
"@babel/core": "^7.22.20",
"@types/yargs": "17.0.32",
"jest": "29.7.0",
"typescript": "5.3.3"
"typescript": "5.3.3",
"vitest": "1.2.1"
},
"gitHead": "3905ed045508b861b495f8d5630d76c7a157d8f1"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { vi, test, expect } from 'vitest'

import { command, description, builder, handler } from '../setup'

// mock Telemetry for CLI commands so they don't try to spawn a process
jest.mock('@redwoodjs/telemetry', () => {
vi.mock('@redwoodjs/telemetry', () => {
return {
errorTelemetry: () => jest.fn(),
timedTelemetry: () => jest.fn(),
Expand Down
7 changes: 7 additions & 0 deletions packages/auth-providers/auth0/setup/vitest.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig, configDefaults } from 'vitest/config'

export default defineConfig({
test: {
exclude: [...configDefaults.exclude, '**/fixtures'],
},
})
5 changes: 0 additions & 5 deletions packages/auth-providers/auth0/web/jest.config.js

This file was deleted.

8 changes: 4 additions & 4 deletions packages/auth-providers/auth0/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"build:types": "tsc --build --verbose",
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
"prepublishOnly": "NODE_ENV=production yarn build",
"test": "jest src",
"test:watch": "yarn test --watch"
"test": "vitest run src",
"test:watch": "vitest watch src"
},
"dependencies": {
"@babel/runtime-corejs3": "7.23.6",
Expand All @@ -32,9 +32,9 @@
"@babel/cli": "7.23.4",
"@babel/core": "^7.22.20",
"@types/react": "18.2.37",
"jest": "29.7.0",
"react": "0.0.0-experimental-e5205658f-20230913",
"typescript": "5.3.3"
"typescript": "5.3.3",
"vitest": "1.2.1"
},
"peerDependencies": {
"@auth0/auth0-spa-js": "2.1.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
User,
} from '@auth0/auth0-spa-js'
import { renderHook, act } from '@testing-library/react'
import { vi, beforeAll, beforeEach, describe, expect, it } from 'vitest'

import type { CurrentUser } from '@redwoodjs/auth'

Expand Down Expand Up @@ -52,7 +53,7 @@ const auth0MockClient: Partial<Auth0Client> = {
},
}

const fetchMock = jest.fn()
const fetchMock = vi.fn()
fetchMock.mockImplementation(async (_url, options) => {
const body = options?.body ? JSON.parse(options.body) : {}

Expand Down
8 changes: 8 additions & 0 deletions packages/auth-providers/auth0/web/vitest.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig, configDefaults } from 'vitest/config'

export default defineConfig({
test: {
exclude: [...configDefaults.exclude, '**/fixtures'],
environment: 'jsdom',
},
})
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7596,10 +7596,10 @@ __metadata:
"@redwoodjs/api": "npm:6.0.7"
"@types/jsonwebtoken": "npm:9.0.5"
core-js: "npm:3.34.0"
jest: "npm:29.7.0"
jsonwebtoken: "npm:9.0.2"
jwks-rsa: "npm:3.1.0"
typescript: "npm:5.3.3"
vitest: "npm:1.2.1"
languageName: unknown
linkType: soft

Expand All @@ -7613,8 +7613,8 @@ __metadata:
"@redwoodjs/cli-helpers": "npm:6.0.7"
"@types/yargs": "npm:17.0.32"
core-js: "npm:3.34.0"
jest: "npm:29.7.0"
typescript: "npm:5.3.3"
vitest: "npm:1.2.1"
languageName: unknown
linkType: soft

Expand All @@ -7629,9 +7629,9 @@ __metadata:
"@redwoodjs/auth": "npm:6.0.7"
"@types/react": "npm:18.2.37"
core-js: "npm:3.34.0"
jest: "npm:29.7.0"
react: "npm:0.0.0-experimental-e5205658f-20230913"
typescript: "npm:5.3.3"
vitest: "npm:1.2.1"
peerDependencies:
"@auth0/auth0-spa-js": 2.1.2
languageName: unknown
Expand Down