Skip to content

Commit

Permalink
test(env): Use vitest in integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy351 committed Feb 11, 2024
1 parent 4d09600 commit 398adae
Show file tree
Hide file tree
Showing 13 changed files with 2,108 additions and 1,289 deletions.
7 changes: 5 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
".mjs",
".json",
".node"
]
],
"allowModules": ["vitest", "vitest/config"]
}
},
"overrides": [
Expand Down Expand Up @@ -127,7 +128,9 @@
"@kosko/env",
"@kosko/generate",
"@kosko/template",
"@kosko/yaml"
"@kosko/yaml",
"vitest",
"vitest/config"
]
}
}
Expand Down
20 changes: 20 additions & 0 deletions internal/vitest-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "@kosko/vitest-config",
"version": "0.0.0",
"private": true,
"sideEffects": false,
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc"
},
"engines": {
"node": ">=18"
},
"devDependencies": {
"typescript": "^5.3.3"
},
"peerDependencies": {
"vitest": "^1.2.2"
}
}
7 changes: 7 additions & 0 deletions internal/vitest-config/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
include: ["**/__tests__/**/*.{js,ts}"]
}
});
9 changes: 9 additions & 0 deletions internal/vitest-config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"module": "commonjs",
"declaration": true
},
"include": ["src"]
}
2 changes: 1 addition & 1 deletion jest.integration.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type { Config } from "jest";

const config: Config = {
projects: ["<rootDir>/packages/*/integration"]
projects: ["<rootDir>/packages/*/integration/jest.config.js"]
};

export default config;
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"watch": "npm run build -- --watch",
"test": "npm-run-all test:*",
"test:unit": "cross-env BUILD_TARGET=node ESM_IMPORT_DISABLED=1 jest",
"test:integration": "jest --config jest.integration.config.ts",
"test:integration": "npm-run-all test:integration:*",
"test:integration:jest": "jest --config jest.integration.config.ts",
"test:integration:vitest": "vitest --workspace vitest.integration.workspace.ts",
"test:browser": "jest --config integration/browser/jest.config.js",
"preinstall": "npx only-allow pnpm",
"prepare": "husky install",
Expand Down Expand Up @@ -67,6 +69,7 @@
"turbo": "^1.8.8",
"typescript": "^5.3.3",
"verdaccio": "^5.19.0",
"vitest": "^1.2.2",
"webpack": "^5.76.0",
"webpack-cli": "^4.10.0"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`should load CJS file 1`] = `"{ type: 'file', ext: 'cjs' }"`;

Expand Down
1 change: 1 addition & 0 deletions packages/env/integration/esm/__tests__/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { dirname, join } from "node:path";
import execa, { NodeOptions } from "execa";
import { expect, test } from "vitest";

const testDir = dirname(__dirname);

Expand Down
3 changes: 0 additions & 3 deletions packages/env/integration/jest.config.js

This file was deleted.

1 change: 1 addition & 0 deletions packages/env/integration/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "@kosko/vitest-config";
4 changes: 3 additions & 1 deletion packages/env/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@
"@kosko/build-scripts": "workspace:^",
"@kosko/jest-preset": "workspace:^",
"@kosko/test-utils": "workspace:^",
"@kosko/vitest-config": "workspace:^",
"@types/node": "^18.11.14",
"execa": "^5.1.1",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
"typescript": "^5.3.3",
"vitest": "^1.2.2"
}
}
Loading

0 comments on commit 398adae

Please sign in to comment.