Skip to content

Commit acba4dc

Browse files
authored
chore: vitest project config (#32447)
* chore: align on vitest versions across the repo, add project vitest config * Apply suggestion from @cacieprins * Apply suggestion from @cacieprins * Apply suggestion from @cacieprins * Apply suggestion from @cacieprins * Update package.json * lockfile, align vite with vitest * add vitest configs to pkgs that were missing it * update build scripts * fix test pattern for vite-dev-server * correct the path for packages/types tests * downgrade vite-dev-server to vitest 2
1 parent 6f4b9a0 commit acba4dc

File tree

16 files changed

+126
-96
lines changed

16 files changed

+126
-96
lines changed
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
import { baseConfig } from '@packages/eslint-config'
1+
import { baseConfig, cliOverrides } from '@packages/eslint-config'
22
import { globalIgnores } from 'eslint/config'
33

44
export default [
55
// these are configured to build in place, rather than in a separate
66
// dist folder, so we need to ignore them
77
globalIgnores(['src/**/*.{js,js.map,d.ts}']),
88
...baseConfig,
9+
...cliOverrides,
910
{
1011
files: ['**/*.spec.ts', '**/*.component.ts'],
1112
languageOptions: {
1213
parserOptions: {
13-
projectService: false,
14+
tsconfigRootDir: __dirname,
1415
},
1516
},
1617
},
17-
{
18-
rules: {
19-
'no-console': 'off',
20-
},
21-
},
2218
]

npm/cypress-schematic/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"description": "Official Cypress schematic for the Angular CLI",
55
"main": "./src",
66
"scripts": {
7-
"build": "tsc -p tsconfig.json",
8-
"build:watch": "tsc -p tsconfig.json --watch",
7+
"build": "tsc -p tsconfig.build.json",
8+
"build:watch": "tsc -p tsconfig.build.json --watch",
99
"lint": "eslint",
1010
"test": "vitest run --no-file-parallelism"
1111
},
@@ -25,7 +25,7 @@
2525
"@types/node": "^22.17.1",
2626
"eslint": "^9.31.0",
2727
"typescript": "~5.4.5",
28-
"vitest": "3.2.4"
28+
"vitest": "^3.2.4"
2929
},
3030
"peerDependencies": {
3131
"@angular/cli": ">=18.0.0",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"noEmit": false
5+
},
6+
"exclude": ["src/**/files-core/**/*", "src/**/files-ct/**/*", "src/**/*.spec.ts"]
7+
}

npm/cypress-schematic/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"declaration": true,
99
"module": "commonjs",
1010
"moduleResolution": "node",
11+
"noEmit": true,
1112
"noEmitOnError": true,
1213
"noFallthroughCasesInSwitch": true,
1314
"noImplicitAny": true,
@@ -27,5 +28,4 @@
2728
"include": [
2829
"src/**/*"
2930
],
30-
"exclude": ["src/**/files-core/**/*", "src/**/files-ct/**/*", "src/**/*.spec.ts"]
3131
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { defineConfig } from 'vitest/config'
2+
3+
export default defineConfig({
4+
test: {
5+
include: ['src/**/*.spec.ts'],
6+
globals: true,
7+
environment: 'node',
8+
},
9+
})

npm/vite-dev-server/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"description": "Launches Vite Dev Server for Component Testing",
55
"main": "dist/index.js",
66
"scripts": {
7-
"build": "tsc || echo 'built, with type errors'",
8-
"check-ts": "tsc --noEmit",
7+
"build": "tsc --project tsconfig.build.json || echo 'built, with type errors'",
8+
"check-ts": "tsc --noEmit --project tsconfig.build.json",
99
"cypress:open": "yarn cypress:run-cypress-in-cypress gulp open --project .",
1010
"cypress:run": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --project . --browser chrome",
1111
"cypress:run-cypress-in-cypress": "cross-env CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT=1 HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS=http://localhost:4455 CYPRESS_REMOTE_DEBUGGING_PORT=6666 TZ=America/New_York",
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"compilerOptions": {
3+
"resolveJsonModule": true,
4+
"target": "ES2020",
5+
"module": "node16",
6+
"moduleResolution": "node16",
7+
"lib": [
8+
"es2015",
9+
"dom"
10+
],
11+
"declaration": true,
12+
"outDir": "dist",
13+
"importHelpers": true,
14+
"strict": true,
15+
"types": [
16+
"cypress"
17+
],
18+
"allowSyntheticDefaultImports": true,
19+
"esModuleInterop": true,
20+
"stripInternal": true,
21+
"ignoreDeprecations": "5.0",
22+
"importsNotUsedAsValues": "error",
23+
"skipLibCheck": true
24+
},
25+
"include": [
26+
"src"
27+
],
28+
"exclude": [
29+
"node_modules",
30+
"*.js"
31+
]
32+
}

npm/vite-dev-server/tsconfig.json

Lines changed: 3 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,4 @@
11
{
2-
"compilerOptions": {
3-
/* Basic Options */
4-
"resolveJsonModule": true,
5-
"target": "ES2020" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */,
6-
"module": "node16" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
7-
"moduleResolution": "node16",
8-
"lib": [
9-
"es2015",
10-
"dom"
11-
] /* Specify library files to be included in the compilation: */,
12-
// "checkJs": true, /* Report errors in .js files. */
13-
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
14-
"declaration": true /* Generates corresponding '.d.ts' file. */,
15-
// "sourceMap": true, /* Generates corresponding '.map' file. */
16-
// "outFile": "./", /* Concatenate and emit output to single file. */
17-
"outDir": "dist" /* Redirect output structure to the directory. */,
18-
// "rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
19-
// "removeComments": true, /* Do not emit comments to output. */
20-
// "noEmit": true, /* Do not emit outputs. */
21-
"importHelpers": true, /* Import emit helpers from 'tslib'. */
22-
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
23-
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
24-
25-
/* Strict Type-Checking Options */
26-
"strict": true /* Enable all strict type-checking options. */,
27-
// "noImplicitAny": true,
28-
29-
/* Module Resolution Options */
30-
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
31-
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
32-
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
33-
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
34-
// "typeRoots": [], /* List of folders to include type definitions from. */
35-
"types": ["cypress"] /* Type declaration files to be included in compilation. */,
36-
"allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */,
37-
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
38-
39-
/* Source Map Options */
40-
// "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
41-
// "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
42-
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
43-
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
44-
45-
/* Experimental Options */
46-
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
47-
"esModuleInterop": true,
48-
/** Allows us to strip internal types sourced from webpack */
49-
"stripInternal": true,
50-
"ignoreDeprecations": "5.0",
51-
/*
52-
* TODO: remove importsNotUsedAsValues after typescript 5.5 and up as it will no longer work. If we want the same behavior
53-
* as importsNotUsedAsValues, we need to use "verbatimModuleSyntax", which will require this package to be an ES Module.
54-
*/
55-
"importsNotUsedAsValues": "error",
56-
/* skips checking declaration types. we skip this because we have multiple versions of vite installed as dev dependencies */
57-
"skipLibCheck": true,
58-
},
59-
"include": ["src"],
60-
"exclude": ["node_modules", "*.js"]
61-
}
2+
"extends": "./tsconfig.build.json",
3+
"include": ["src", "test"]
4+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { defineConfig } from 'vitest/config'
2+
3+
export default defineConfig({
4+
test: {
5+
include: ['test/**/*.spec.ts'],
6+
globals: true,
7+
environment: 'node',
8+
},
9+
})

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
"@typescript-eslint/eslint-plugin": "7.2.0",
126126
"@typescript-eslint/parser": "7.2.0",
127127
"@urql/introspection": "^0.3.0",
128+
"@vitest/coverage-v8": "^3.2.4",
128129
"ascii-table": "0.0.9",
129130
"autobarrel": "^1.1.0",
130131
"bluebird": "3.5.3",
@@ -211,6 +212,7 @@
211212
"tree-kill": "1.2.2",
212213
"ts-node": "^10.9.2",
213214
"typescript": "5.3.3",
215+
"vitest": "^3.2.4",
214216
"yaml": "2.8.0",
215217
"yarn-deduplicate": "3.1.0"
216218
},

0 commit comments

Comments
 (0)