
10 changed files with 177 additions and 1946 deletions
-
67jest.config.js
-
15package.json
-
1packages/vue/src/dev.ts
-
1883pnpm-lock.yaml
-
18scripts/filter-e2e.js
-
10scripts/filter-unit.js
-
92scripts/setupJestEnv.ts
-
17vitest.config.ts
-
10vitest.e2e.config.ts
-
10vitest.unit.config.ts
@ -1,67 +0,0 @@ |
|||
module.exports = { |
|||
testEnvironment: 'jsdom', |
|||
preset: 'ts-jest', |
|||
setupFilesAfterEnv: ['./scripts/setupJestEnv.ts'], |
|||
transform: { |
|||
'^.+\\.tsx?$': [ |
|||
'ts-jest', |
|||
{ |
|||
tsconfig: { |
|||
target: 'esnext', |
|||
sourceMap: true |
|||
} |
|||
} |
|||
] |
|||
}, |
|||
globals: { |
|||
__DEV__: true, |
|||
__TEST__: true, |
|||
__VERSION__: require('./package.json').version, |
|||
__BROWSER__: false, |
|||
__GLOBAL__: false, |
|||
__ESM_BUNDLER__: true, |
|||
__ESM_BROWSER__: false, |
|||
__NODE_JS__: true, |
|||
__SSR__: true, |
|||
__FEATURE_OPTIONS_API__: true, |
|||
__FEATURE_SUSPENSE__: true, |
|||
__FEATURE_PROD_DEVTOOLS__: false, |
|||
__COMPAT__: true |
|||
}, |
|||
coverageDirectory: 'coverage', |
|||
coverageReporters: ['html', 'lcov', 'text'], |
|||
collectCoverageFrom: [ |
|||
'packages/*/src/**/*.ts', |
|||
'!packages/runtime-test/src/utils/**', |
|||
'!packages/template-explorer/**', |
|||
'!packages/sfc-playground/**', |
|||
'!packages/size-check/**', |
|||
'!packages/runtime-core/src/profiling.ts', |
|||
'!packages/runtime-core/src/customFormatter.ts', |
|||
// DOM transitions are tested via e2e so no coverage is collected
|
|||
'!packages/runtime-dom/src/components/Transition*', |
|||
// only called in browsers
|
|||
'!packages/vue/src/devCheck.ts', |
|||
// only used as a build entry
|
|||
'!packages/vue/src/runtime.ts', |
|||
// mostly just entries
|
|||
'!packages/vue-compat/**' |
|||
], |
|||
watchPathIgnorePatterns: ['/node_modules/', '/dist/', '/.git/'], |
|||
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'], |
|||
moduleNameMapper: { |
|||
'@vue/consolidate': '@vue/consolidate', |
|||
'@vue/compat': '<rootDir>/packages/vue-compat/src', |
|||
'^@vue/(.*?)$': '<rootDir>/packages/$1/src', |
|||
'vue/compiler-sfc': '<rootDir>/packages/compiler-sfc/src', |
|||
'vue/server-renderer': '<rootDir>/packages/server-renderer/src', |
|||
vue: '<rootDir>/packages/vue/src' |
|||
}, |
|||
rootDir: __dirname, |
|||
testMatch: ['<rootDir>/packages/**/__tests__/**/*spec.[jt]s?(x)'], |
|||
testPathIgnorePatterns: process.env.SKIP_E2E |
|||
? // ignore example tests on netlify builds since they don't contribute
|
|||
// to coverage and can cause netlify builds to fail
|
|||
['/node_modules/', '/examples/__tests__'] |
|||
: ['/node_modules/'] |
|||
} |
1883
pnpm-lock.yaml
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,18 +0,0 @@ |
|||
// jest only supports cjs filter files
|
|||
const path = require('path') |
|||
|
|||
const e2eTests = [ |
|||
'vue/__tests__/Transition', |
|||
'vue/__tests__/TransitionGroup', |
|||
'vue/examples/' |
|||
] |
|||
|
|||
module.exports = list => { |
|||
return { |
|||
filtered: list |
|||
.filter(t => e2eTests.some(tt => t.includes(path.normalize(tt)))) |
|||
.map(test => ({ test })) |
|||
} |
|||
} |
|||
|
|||
module.exports.e2eTests = e2eTests |
@ -1,10 +0,0 @@ |
|||
// jest only supports cjs filter files
|
|||
const { e2eTests } = require('./filter-e2e') |
|||
|
|||
module.exports = list => { |
|||
return { |
|||
filtered: list |
|||
.filter(t => !e2eTests.some(tt => t.includes(tt))) |
|||
.map(test => ({ test })) |
|||
} |
|||
} |
@ -1,92 +0,0 @@ |
|||
expect.extend({ |
|||
toHaveBeenWarned(received: string) { |
|||
asserted.add(received) |
|||
const passed = warn.mock.calls.some(args => args[0].includes(received)) |
|||
if (passed) { |
|||
return { |
|||
pass: true, |
|||
message: () => `expected "${received}" not to have been warned.` |
|||
} |
|||
} else { |
|||
const msgs = warn.mock.calls.map(args => args[0]).join('\n - ') |
|||
return { |
|||
pass: false, |
|||
message: () => |
|||
`expected "${received}" to have been warned` + |
|||
(msgs.length |
|||
? `.\n\nActual messages:\n\n - ${msgs}` |
|||
: ` but no warning was recorded.`) |
|||
} |
|||
} |
|||
}, |
|||
|
|||
toHaveBeenWarnedLast(received: string) { |
|||
asserted.add(received) |
|||
const passed = |
|||
warn.mock.calls[warn.mock.calls.length - 1][0].includes(received) |
|||
if (passed) { |
|||
return { |
|||
pass: true, |
|||
message: () => `expected "${received}" not to have been warned last.` |
|||
} |
|||
} else { |
|||
const msgs = warn.mock.calls.map(args => args[0]).join('\n - ') |
|||
return { |
|||
pass: false, |
|||
message: () => |
|||
`expected "${received}" to have been warned last.\n\nActual messages:\n\n - ${msgs}` |
|||
} |
|||
} |
|||
}, |
|||
|
|||
toHaveBeenWarnedTimes(received: string, n: number) { |
|||
asserted.add(received) |
|||
let found = 0 |
|||
warn.mock.calls.forEach(args => { |
|||
if (args[0].includes(received)) { |
|||
found++ |
|||
} |
|||
}) |
|||
|
|||
if (found === n) { |
|||
return { |
|||
pass: true, |
|||
message: () => `expected "${received}" to have been warned ${n} times.` |
|||
} |
|||
} else { |
|||
return { |
|||
pass: false, |
|||
message: () => |
|||
`expected "${received}" to have been warned ${n} times but got ${found}.` |
|||
} |
|||
} |
|||
} |
|||
}) |
|||
|
|||
let warn: jest.SpyInstance |
|||
const asserted: Set<string> = new Set() |
|||
|
|||
beforeEach(() => { |
|||
asserted.clear() |
|||
warn = jest.spyOn(console, 'warn') |
|||
warn.mockImplementation(() => {}) |
|||
}) |
|||
|
|||
afterEach(() => { |
|||
const assertedArray = Array.from(asserted) |
|||
const nonAssertedWarnings = warn.mock.calls |
|||
.map(args => args[0]) |
|||
.filter(received => { |
|||
return !assertedArray.some(assertedMsg => { |
|||
return received.includes(assertedMsg) |
|||
}) |
|||
}) |
|||
warn.mockRestore() |
|||
if (nonAssertedWarnings.length) { |
|||
throw new Error( |
|||
`test case threw unexpected warnings:\n - ${nonAssertedWarnings.join( |
|||
'\n - ' |
|||
)}`
|
|||
) |
|||
} |
|||
}) |
@ -0,0 +1,10 @@ |
|||
import { UserConfig, configDefaults } from 'vitest/config' |
|||
import config from './vitest.config' |
|||
|
|||
export default { |
|||
...config, |
|||
test: { |
|||
...config.test, |
|||
include: ['packages/vue/__tests__/e2e/*.spec.ts'] |
|||
} |
|||
} as UserConfig |
@ -0,0 +1,10 @@ |
|||
import { UserConfig, configDefaults } from 'vitest/config' |
|||
import config from './vitest.config' |
|||
|
|||
export default { |
|||
...config, |
|||
test: { |
|||
...config.test, |
|||
exclude: [...configDefaults.exclude, '**/e2e/**'] |
|||
} |
|||
} as UserConfig |
Write
Preview
Loading…
Cancel
Save
Reference in new issue