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

Upgrade vitest #4073

Merged
merged 7 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@
"testing.automaticallyOpenPeekView": "never",
"javascript.preferences.importModuleSpecifierEnding": "js",
"typescript.preferences.importModuleSpecifierEnding": "js",
"vitest.nodeEnv": {"VITEST_SKIP_TIMEOUT": "1"}
}
5 changes: 5 additions & 0 deletions configurations/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {defineConfig} from 'vitest/config'
export default function config(packagePath: string) {
// always treat environment as one that doesn't support hyperlinks -- otherwise assertions are hard to keep consistent
process.env['FORCE_HYPERLINK'] = '0'
process.env['FORCE_COLOR'] = '1'

return defineConfig({
resolve: {
Expand All @@ -16,6 +17,7 @@ export default function config(packagePath: string) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
test: {
testTimeout: process.env['VITEST_SKIP_TIMEOUT'] === '1' ? 180000 : 5000,
clearMocks: true,
mockReset: true,
setupFiles: [path.join(__dirname, './vitest/setup.js')],
Expand All @@ -27,6 +29,9 @@ export default function config(packagePath: string) {
all: true,
reporter: ['text', 'json', 'lcov'],
},
snapshotFormat: {
escapeString: true,
},
},
})
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"version": "0.0.0",
"resolutions": {
"@types/react": "17.0.2",
"vite": "4.4.9",
"vite": "5.3.1",
"@oclif/core": "3.26.5",
"whatwg-url": "14.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you check if we can remove this? A punycode warning was shown with Node 22, and I think vite was one of the culprits.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it can be removed. The extensions console uses vite to build for instance

Copy link
Contributor

@gonzaloriestra gonzaloriestra Jun 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant whatwg-url. Maybe with the Vite upgrade we don't need to pin this version anymore.

"@shopify/cli-hydrogen>@shopify/cli-kit": "link:./packages/cli-kit",
Expand Down
4 changes: 2 additions & 2 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@
"@types/react": "18.2.0",
"@types/react-dom": "18.2.0",
"@types/ws": "^8.5.5",
"@vitest/coverage-istanbul": "^0.34.3",
"@vitest/coverage-istanbul": "^1.6.0",
"graphql": "^16.8.1",
"graphql-tag": "^2.12.6",
"vitest": "^0.34.3"
"vitest": "^1.6.0"
},
"engines": {
"node": "^18.20.0 || >=20.10.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('setupWebsocketConnection', () => {

beforeEach(() => {
vi.useFakeTimers()
vi.mocked(WebSocketServer).mockReturnValue(websocketServer)
})

afterEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/cli/services/generate/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ describe('initialize a extension', async () => {
})

// Then
await expect(got).rejects.toThrowErrorMatchingInlineSnapshot('"No folder for selected flavor"')
await expect(got).rejects.toThrowErrorMatchingInlineSnapshot('[Error: No folder for selected flavor]')
expect(file.fileExistsSync(joinPath(tmpDir, 'extensions', name))).toBeFalsy()
})
})
Expand Down
4 changes: 2 additions & 2 deletions packages/cli-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@
"@types/node": "18.19.3",
"@types/react": "18.2.0",
"@types/semver": "^7.5.2",
"@vitest/coverage-istanbul": "^0.34.3",
"@vitest/coverage-istanbul": "^1.6.0",
"node-stream-zip": "^1.15.0",
"ts-morph": "^17.0.1",
"typedoc": "^0.25.7",
"typescript": "5.2.2",
"vitest": "^0.34.3"
"vitest": "^1.6.0"
},
"engines": {
"node": "^18.20.0 || >=20.10.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@
"@shopify/theme": "3.62.0",
"@shopify/cli-hydrogen": "0.0.0-next-9eb60d7-20240607102913",
"@types/node": "18.19.3",
"@vitest/coverage-istanbul": "^0.34.3",
"@vitest/coverage-istanbul": "^1.6.0",
"esbuild-plugin-copy": "^2.1.1",
"espree": "9.6.1",
"vitest": "^0.34.3",
"vitest": "^1.6.0",
"zod-to-json-schema": "3.21.4"
},
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions packages/create-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"@shopify/cli-kit": "3.62.0",
"@types/node": "18.19.3",
"esbuild-plugin-copy": "^2.1.1",
"@vitest/coverage-istanbul": "^0.34.3",
"vitest": "^0.34.3"
"@vitest/coverage-istanbul": "^1.6.0",
"vitest": "^1.6.0"
},
"engines": {
"node": "^18.20.0 || >=20.10.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
"@shopify/cli-kit": "3.62.0"
},
"devDependencies": {
"@vitest/coverage-istanbul": "^0.34.3",
"vitest": "^0.34.3"
"@vitest/coverage-istanbul": "^1.6.0",
"vitest": "^1.6.0"
},
"engines": {
"node": "^18.20.0 || >=20.10.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-did-you-mean/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"n-gram": "2.0.2"
},
"devDependencies": {
"@vitest/coverage-istanbul": "^0.34.3",
"vitest": "^0.34.3"
"@vitest/coverage-istanbul": "^1.6.0",
"vitest": "^1.6.0"
},
"engines": {
"node": "^18.20.0 || >=20.10.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
},
"devDependencies": {
"@types/node": "18.19.3",
"@vitest/coverage-istanbul": "^0.34.3",
"@vitest/coverage-istanbul": "^1.6.0",
"node-stream-zip": "^1.15.0",
"vitest": "^0.34.3"
"vitest": "^1.6.0"
},
"engines": {
"node": "^18.20.0 || >=20.10.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/theme/src/cli/commands/theme/check.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Check from './check.js'
import {describe, vi, expect, test, beforeEach, afterAll, SpyInstance} from 'vitest'
import {describe, vi, expect, test, beforeEach, afterAll, MockInstance} from 'vitest'
import {Config} from '@oclif/core'
import {themeCheckRun, Theme, Config as ThemeConfig, Offense} from '@shopify/theme-check-node'

vi.mock('@shopify/theme-check-node')
const CommandConfig = new Config({root: __dirname})

describe('Check', () => {
let exitSpy: SpyInstance
let exitSpy: MockInstance<[code?: number | undefined], never>

beforeEach(() => {
// Create a spy on process.exit
Expand Down
4 changes: 2 additions & 2 deletions packages/theme/src/cli/services/check.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {fileExists, readFileSync, writeFile} from '@shopify/cli-kit/node/fs'
import {outputInfo, outputSuccess} from '@shopify/cli-kit/node/output'
import {renderInfo} from '@shopify/cli-kit/node/ui'
import {Severity, SourceCodeType, loadConfig, type Offense, type Theme} from '@shopify/theme-check-node'
import {Mock, SpyInstance, afterAll, beforeEach, describe, expect, test, vi} from 'vitest'
import {Mock, MockInstance, afterAll, beforeEach, describe, expect, test, vi} from 'vitest'

vi.mock('@shopify/cli-kit/node/fs', async () => ({
fileExists: vi.fn(),
Expand Down Expand Up @@ -309,7 +309,7 @@ describe('formatOffensesJson', () => {
})

describe('handleExit', () => {
let exitSpy: SpyInstance
let exitSpy: MockInstance<[code?: number | undefined], never>

beforeEach(() => {
// Create a spy on process.exit
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-extensions-dev-console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"jsdom": "^20.0.3",
"sass": "^1.64.2",
"typescript": "5.2.2",
"vite": "^4.4.9",
"vitest": "^0.34.3"
"vite": "^5.3.1",
"vitest": "^1.6.0"
}
}
4 changes: 2 additions & 2 deletions packages/ui-extensions-server-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
"react": "^17.0.2",
"typescript": "5.2.2",
"vi-fetch": "^0.8.0",
"vite": "^4.4.9",
"vitest": "^0.34.3"
"vite": "^5.3.1",
"vitest": "^1.6.0"
},
"peerDependencies": {
"react": "^17.0.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-extensions-server-kit/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"types": ["vitest/globals", "vi-fetch/matchers"],
"allowJs": false,
"skipLibCheck": false,
"skipLibCheck": true,
"esModuleInterop": true,
"declaration": true,
"composite": true,
Expand Down
Loading