From dd84b9d64fb98746a230cd24233ff50a562c39c9 Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Fri, 28 Apr 2023 01:36:44 +0800 Subject: --- cli/scripts/templates/jest.config.js | 10 ++++++++++ cli/scripts/templates/src/__tests__/index.test.ts | 7 +++++++ cli/scripts/templates/src/__tests__/tsconfig.json | 4 ++++ cli/scripts/templates/src/index.ts | 3 +++ cli/scripts/templates/tsconfig.json | 9 +++++++++ 5 files changed, 33 insertions(+) create mode 100644 cli/scripts/templates/jest.config.js create mode 100644 cli/scripts/templates/src/__tests__/index.test.ts create mode 100644 cli/scripts/templates/src/__tests__/tsconfig.json create mode 100644 cli/scripts/templates/src/index.ts create mode 100644 cli/scripts/templates/tsconfig.json (limited to 'cli/scripts/templates') diff --git a/cli/scripts/templates/jest.config.js b/cli/scripts/templates/jest.config.js new file mode 100644 index 0000000..0548306 --- /dev/null +++ b/cli/scripts/templates/jest.config.js @@ -0,0 +1,10 @@ +module.exports = { + roots: ["/src"], + transform: { + "^.+\\.tsx?$": "ts-jest", + }, + // testRegex: '(/__tests__/.*(\\.|/)(test|spec))\\.tsx?$', + moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"], + modulePathIgnorePatterns: ["/src/__fixtures__"], + preset: "ts-jest", +}; diff --git a/cli/scripts/templates/src/__tests__/index.test.ts b/cli/scripts/templates/src/__tests__/index.test.ts new file mode 100644 index 0000000..9a4831a --- /dev/null +++ b/cli/scripts/templates/src/__tests__/index.test.ts @@ -0,0 +1,7 @@ +import { sum } from "../."; + +describe("Hello", () => { + it("renders without crashing", () => { + expect(sum(1, 2)).toEqual(3); + }); +}); diff --git a/cli/scripts/templates/src/__tests__/tsconfig.json b/cli/scripts/templates/src/__tests__/tsconfig.json new file mode 100644 index 0000000..bf65be6 --- /dev/null +++ b/cli/scripts/templates/src/__tests__/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": [".", "../."] +} diff --git a/cli/scripts/templates/src/index.ts b/cli/scripts/templates/src/index.ts new file mode 100644 index 0000000..715e93e --- /dev/null +++ b/cli/scripts/templates/src/index.ts @@ -0,0 +1,3 @@ +export const sum = (a: number, b: number) => { + return a + b; +}; diff --git a/cli/scripts/templates/tsconfig.json b/cli/scripts/templates/tsconfig.json new file mode 100644 index 0000000..76ae392 --- /dev/null +++ b/cli/scripts/templates/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "dist" + }, + "include": ["src"], + "exclude": ["node_modules"] +} -- cgit v1.2.3-70-g09d2