Skip to content

Commit

Permalink
test(yaml): 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 5fa5429 commit 3bd0577
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 11 deletions.
6 changes: 6 additions & 0 deletions internal/vitest-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ export default defineConfig({
include: ["**/__tests__/**/*.{js,ts}"]
}
});

export const integration = defineConfig({
test: {
include: ["integration/**/__tests__/**/*.{js,ts}"]
}
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"test:unit": "cross-env BUILD_TARGET=node ESM_IMPORT_DISABLED=1 jest",
"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:integration:vitest": "vitest --workspace vitest.workspace.integration.ts",
"test:browser": "jest --config integration/browser/jest.config.js",
"preinstall": "npx only-allow pnpm",
"prepare": "husky install",
Expand Down
1 change: 0 additions & 1 deletion packages/env/integration/vitest.config.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/env/vitest.config.integration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { integration as default } from "@kosko/vitest-config";
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 Kubernetes objects 1`] = `
"[
Expand Down
1 change: 1 addition & 0 deletions packages/yaml/integration/esm/__tests__/load.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import execa from "execa";
import { dirname, join } from "node:path";
import { installPackage } from "@kosko/test-utils";
import { beforeAll, test, expect } from "vitest";

const testDir = dirname(__dirname);

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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`when fetch is not polyfilled should be able to fetch 1`] = `
exports[`when fetch is not polyfilled > should be able to fetch 1`] = `
"[
Pod { apiVersion: 'v1', kind: 'Pod', metadata: { name: 'test-pod' } }
]"
`;

exports[`when fetch is polyfilled should be able to fetch 1`] = `
exports[`when fetch is polyfilled > should be able to fetch 1`] = `
"[
Pod { apiVersion: 'v1', kind: 'Pod', metadata: { name: 'test-pod' } }
]"
Expand Down
1 change: 1 addition & 0 deletions packages/yaml/integration/load-url/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { dirname, join } from "node:path";
import { installPackage } from "@kosko/test-utils";
import { createServer, Server } from "node:http";
import { AddressInfo } from "node:net";
import { beforeAll, afterAll, describe, expect, test } from "vitest";

const testDir = dirname(__dirname);
let server: Server;
Expand Down
4 changes: 3 additions & 1 deletion packages/yaml/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@
"@kosko/build-scripts": "workspace:^",
"@kosko/jest-preset": "workspace:^",
"@kosko/test-utils": "workspace:^",
"@kosko/vitest-config": "workspace:^",
"@types/js-yaml": "^4.0.5",
"@types/node-fetch": "^2.6.2",
"cross-fetch": "^3.1.5",
"execa": "^5.1.1",
"fetch-mock": "^9.11.0",
"kubernetes-models": "^4.1.0"
"kubernetes-models": "^4.1.0",
"vitest": "^1.2.2"
},
"peerDependencies": {
"kubernetes-models": ">=1.0.3"
Expand Down
1 change: 1 addition & 0 deletions packages/yaml/vitest.config.integration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { integration as default } from "@kosko/vitest-config";
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"packages/*/dist",
"packages/*/lib",
"packages/*/integration",
"packages/*/vitest.config.integration.ts",
"**/__tests__/**",
"**/__fixtures/**"
]
Expand Down
1 change: 0 additions & 1 deletion vitest.integration.workspace.ts

This file was deleted.

1 change: 1 addition & 0 deletions vitest.workspace.integration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default ["packages/*/vitest.config.integration.ts"];

0 comments on commit 3bd0577

Please sign in to comment.