@tsed/cli-plugin-vitest 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +13 -0
- package/.eslintrc.js +1 -0
- package/jest.config.js +15 -0
- package/lib/cjs/CliPluginVitestModule.js +55 -0
- package/lib/cjs/CliPluginVitestModule.js.map +1 -0
- package/lib/cjs/hooks/VitestGenerateHook.js +65 -0
- package/lib/cjs/hooks/VitestGenerateHook.js.map +1 -0
- package/lib/cjs/hooks/VitestInitHook.js +51 -0
- package/lib/cjs/hooks/VitestInitHook.js.map +1 -0
- package/lib/cjs/index.js +7 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/utils/templateDir.js +6 -0
- package/lib/cjs/utils/templateDir.js.map +1 -0
- package/lib/esm/CliPluginVitestModule.js +52 -0
- package/lib/esm/CliPluginVitestModule.js.map +1 -0
- package/lib/esm/hooks/VitestGenerateHook.js +62 -0
- package/lib/esm/hooks/VitestGenerateHook.js.map +1 -0
- package/lib/esm/hooks/VitestInitHook.js +48 -0
- package/lib/esm/hooks/VitestInitHook.js.map +1 -0
- package/lib/esm/index.js +4 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/package.json +3 -0
- package/lib/esm/utils/templateDir.js +5 -0
- package/lib/esm/utils/templateDir.js.map +1 -0
- package/lib/tsconfig.esm.tsbuildinfo +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/CliPluginVitestModule.d.ts +9 -0
- package/lib/types/hooks/VitestGenerateHook.d.ts +7 -0
- package/lib/types/hooks/VitestInitHook.d.ts +11 -0
- package/lib/types/index.d.ts +3 -0
- package/lib/types/utils/templateDir.d.ts +1 -0
- package/package.json +43 -0
- package/readme.md +31 -0
- package/scripts/templateDir.esm.js +5 -0
- package/templates/generate/decorator.class.spec.hbs +12 -0
- package/templates/generate/decorator.endpoint.spec.hbs +16 -0
- package/templates/generate/decorator.method.spec.hbs +14 -0
- package/templates/generate/decorator.param.spec.hbs +15 -0
- package/templates/generate/decorator.parameter.spec.hbs +13 -0
- package/templates/generate/decorator.prop.spec.hbs +16 -0
- package/templates/generate/decorator.property.spec.hbs +14 -0
- package/templates/generate/generic.integration.hbs +21 -0
- package/templates/generate/generic.spec.hbs +15 -0
- package/templates/generate/server.integration.hbs +21 -0
- package/templates/init/vitest.config.mts.hbs +16 -0
- package/tsconfig.esm.json +39 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { expect, describe, it } from "vitest";
|
|
2
|
+
import { Store } from "@tsed/core";
|
|
3
|
+
import { {{symbolName}} } from "./{{symbolPathBasename}}";
|
|
4
|
+
|
|
5
|
+
describe("{{symbolName}}", () => {
|
|
6
|
+
it("should store options", () => {
|
|
7
|
+
class Test {
|
|
8
|
+
@{{symbolName}}({options: "options"})
|
|
9
|
+
property: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const store = Store.from(Test, "property");
|
|
13
|
+
|
|
14
|
+
expect(store.get({{symbolName}})).toEqual({options: "options"});
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { expect, describe, it } from "vitest";
|
|
2
|
+
import { {{symbolName}} } from "./{{symbolPathBasename}}";
|
|
3
|
+
|
|
4
|
+
describe("{{symbolName}}", () => {
|
|
5
|
+
it("should do something", () => {
|
|
6
|
+
class Test {
|
|
7
|
+
@{{symbolName}}({})
|
|
8
|
+
property: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
expect(typeof {{symbolName}}).toBe("function")
|
|
12
|
+
expect(typeof {{symbolName}}()).toBe("function")
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { expect, describe, it, afterAll, beforeAll } from "vitest";
|
|
2
|
+
import { PlatformTest } from "@tsed/common";
|
|
3
|
+
import SuperTest from "supertest";
|
|
4
|
+
import { {{symbolName}} } from "./{{symbolPathBasename}}";
|
|
5
|
+
import { Server } from "{{relativeSrcPath}}/Server";
|
|
6
|
+
|
|
7
|
+
describe("{{symbolName}}", () => {
|
|
8
|
+
beforeAll(PlatformTest.bootstrap(Server, {
|
|
9
|
+
mount: {
|
|
10
|
+
"/": [{{symbolName}}]
|
|
11
|
+
}
|
|
12
|
+
}));
|
|
13
|
+
afterAll(PlatformTest.reset);
|
|
14
|
+
|
|
15
|
+
it("should call GET {{route}}", async () => {
|
|
16
|
+
const request = SuperTest(PlatformTest.callback());
|
|
17
|
+
const response = await request.get("{{route}}").expect(200);
|
|
18
|
+
|
|
19
|
+
expect(response.text).toEqual("hello");
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { expect, describe, it, beforeEach, afterEach } from "vitest";
|
|
2
|
+
import { PlatformTest } from "@tsed/common";
|
|
3
|
+
import { {{symbolName}} } from "./{{symbolPathBasename}}";
|
|
4
|
+
|
|
5
|
+
describe("{{symbolName}}", () => {
|
|
6
|
+
beforeEach(PlatformTest.create);
|
|
7
|
+
afterEach(PlatformTest.reset);
|
|
8
|
+
|
|
9
|
+
it("should do something", () => {
|
|
10
|
+
const instance = PlatformTest.get<{{symbolName}}>({{symbolName}});
|
|
11
|
+
// const instance = PlatformTest.invoke<{{symbolName}}>({{symbolName}}); // get fresh instance
|
|
12
|
+
|
|
13
|
+
expect(instance).toBeInstanceOf({{symbolName}});
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { expect, describe, it, beforeAll, afterAll } from "vitest";
|
|
2
|
+
import { PlatformTest } from "@tsed/common";
|
|
3
|
+
import SuperTest from "supertest";
|
|
4
|
+
import { {{symbolName}} } from "./{{symbolPathBasename}}";
|
|
5
|
+
|
|
6
|
+
describe("{{symbolName}}", () => {
|
|
7
|
+
beforeAll(PlatformTest.bootstrap({{symbolName}}));
|
|
8
|
+
afterAll(PlatformTest.reset);
|
|
9
|
+
|
|
10
|
+
it("should call GET {{route}}", async () => {
|
|
11
|
+
const request = SuperTest(PlatformTest.callback());
|
|
12
|
+
const response = await request.get("{{route}}").expect(404);
|
|
13
|
+
|
|
14
|
+
expect(response.body).toEqual({
|
|
15
|
+
errors: [],
|
|
16
|
+
message: 'Resource "/rest" not found',
|
|
17
|
+
name: "NOT_FOUND",
|
|
18
|
+
status: 404,
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import swc from "unplugin-swc";
|
|
2
|
+
import {defineConfig} from "vitest/config";
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
test: {
|
|
6
|
+
globals: true,
|
|
7
|
+
root: "./"
|
|
8
|
+
},
|
|
9
|
+
plugins: [
|
|
10
|
+
// This is required to build the test files with SWC
|
|
11
|
+
swc.vite({
|
|
12
|
+
// Explicitly set the module type to avoid inheriting this value from a `.swcrc` config file
|
|
13
|
+
module: {type: "es6"}
|
|
14
|
+
})
|
|
15
|
+
]
|
|
16
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@tsed/typescript/tsconfig.node.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": ".",
|
|
5
|
+
"module": "ES2020",
|
|
6
|
+
"rootDir": "src",
|
|
7
|
+
"outDir": "./lib/esm",
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"declarationDir": "./lib/types",
|
|
10
|
+
"composite": true,
|
|
11
|
+
"noEmit": false
|
|
12
|
+
},
|
|
13
|
+
"include": [
|
|
14
|
+
"src",
|
|
15
|
+
"src/**/*.json"
|
|
16
|
+
],
|
|
17
|
+
"exclude": [
|
|
18
|
+
"node_modules",
|
|
19
|
+
"test",
|
|
20
|
+
"lib",
|
|
21
|
+
"benchmark",
|
|
22
|
+
"coverage",
|
|
23
|
+
"spec",
|
|
24
|
+
"**/*.benchmark.ts",
|
|
25
|
+
"**/*.spec.ts",
|
|
26
|
+
"keys",
|
|
27
|
+
"jest.config.js",
|
|
28
|
+
"**/__mock__/**",
|
|
29
|
+
"webpack.config.js"
|
|
30
|
+
],
|
|
31
|
+
"references": [
|
|
32
|
+
{
|
|
33
|
+
"path": "../cli"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "../cli-core"
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|