Skip to content

Commit eaff22a

Browse files
committed
(jest): typescript
1 parent e44ba00 commit eaff22a

7 files changed

+266
-4
lines changed

vue/jest/babel.config.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
'@babel/preset-env',
5+
{
6+
targets: {
7+
node: 'current',
8+
},
9+
},
10+
],
11+
'@babel/preset-typescript',
12+
],
13+
};

vue/jest/index.js

-4
This file was deleted.
File renamed without changes.
File renamed without changes.

vue/jest/index.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* ../../node_modules/.bin/jest -c ./jest.config.js
3+
*/
4+
5+
export function sum(a, b) {
6+
return a + b;
7+
}

vue/jest/jest.config.js

+187
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
// For a detailed explanation regarding each configuration property, visit:
2+
// https://jestjs.io/docs/en/configuration.html
3+
4+
module.exports = {
5+
// All imported modules in your tests should be mocked automatically
6+
// automock: false,
7+
8+
// Stop running tests after `n` failures
9+
// bail: 0,
10+
11+
// Respect "browser" field in package.json when resolving modules
12+
// browser: false,
13+
14+
// The directory where Jest should store its cached dependency information
15+
// cacheDirectory: "/private/var/folders/_y/sp35zjv13w70bynj3ngs2qgc0000gn/T/jest_dx",
16+
17+
// Automatically clear mock calls and instances between every test
18+
clearMocks: true,
19+
20+
// Indicates whether the coverage information should be collected while executing the test
21+
// collectCoverage: false,
22+
23+
// An array of glob patterns indicating a set of files for which coverage information should be collected
24+
// collectCoverageFrom: null,
25+
26+
// The directory where Jest should output its coverage files
27+
coverageDirectory: "coverage",
28+
29+
// An array of regexp pattern strings used to skip coverage collection
30+
// coveragePathIgnorePatterns: [
31+
// "/node_modules/"
32+
// ],
33+
34+
// A list of reporter names that Jest uses when writing coverage reports
35+
// coverageReporters: [
36+
// "json",
37+
// "text",
38+
// "lcov",
39+
// "clover"
40+
// ],
41+
42+
// An object that configures minimum threshold enforcement for coverage results
43+
// coverageThreshold: null,
44+
45+
// A path to a custom dependency extractor
46+
// dependencyExtractor: null,
47+
48+
// Make calling deprecated APIs throw helpful error messages
49+
// errorOnDeprecated: false,
50+
51+
// Force coverage collection from ignored files using an array of glob patterns
52+
// forceCoverageMatch: [],
53+
54+
// A path to a module which exports an async function that is triggered once before all test suites
55+
// globalSetup: null,
56+
57+
// A path to a module which exports an async function that is triggered once after all test suites
58+
// globalTeardown: null,
59+
60+
// A set of global variables that need to be available in all test environments
61+
// globals: {},
62+
63+
// An array of directory names to be searched recursively up from the requiring module's location
64+
// moduleDirectories: [
65+
// "node_modules"
66+
// ],
67+
68+
// An array of file extensions your modules use
69+
moduleFileExtensions: [
70+
"js",
71+
// "json",
72+
// "jsx",
73+
"ts",
74+
"tsx",
75+
// "node"
76+
],
77+
78+
// A map from regular expressions to module names that allow to stub out resources with a single module
79+
// moduleNameMapper: {},
80+
81+
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
82+
// modulePathIgnorePatterns: [],
83+
84+
// Activates notifications for test results
85+
notify: true,
86+
87+
// An enum that specifies notification mode. Requires { notify: true }
88+
// notifyMode: "failure-change",
89+
90+
// A preset that is used as a base for Jest's configuration
91+
// preset: null,
92+
93+
// Run tests from one or more projects
94+
// projects: null,
95+
96+
// Use this configuration option to add custom reporters to Jest
97+
// reporters: undefined,
98+
99+
// Automatically reset mock state between every test
100+
// resetMocks: false,
101+
102+
// Reset the module registry before running each individual test
103+
// resetModules: false,
104+
105+
// A path to a custom resolver
106+
// resolver: null,
107+
108+
// Automatically restore mock state between every test
109+
// restoreMocks: false,
110+
111+
// The root directory that Jest should scan for tests and modules within
112+
rootDir: '.',
113+
114+
// A list of paths to directories that Jest should use to search for files in
115+
roots: [
116+
// "<rootDir>"
117+
"."
118+
],
119+
120+
// Allows you to use a custom runner instead of Jest's default test runner
121+
// runner: "jest-runner",
122+
123+
// The paths to modules that run some code to configure or set up the testing environment before each test
124+
// setupFiles: [],
125+
126+
// A list of paths to modules that run some code to configure or set up the testing framework before each test
127+
// setupFilesAfterEnv: [],
128+
129+
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
130+
// snapshotSerializers: [],
131+
132+
// The test environment that will be used for testing
133+
testEnvironment: "node",
134+
135+
// Options that will be passed to the testEnvironment
136+
// testEnvironmentOptions: {},
137+
138+
// Adds a location field to test results
139+
// testLocationInResults: false,
140+
141+
// The glob patterns Jest uses to detect test files
142+
testMatch: [
143+
// "**/__tests__/**/*.[jt]s?(x)",
144+
"**/?(*.)+(spec|test).[tj]s?(x)"
145+
// "vue/jest/?(*.)+(spec|test).[tj]s?(x)"
146+
],
147+
148+
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
149+
testPathIgnorePatterns: [
150+
"/node_modules/"
151+
],
152+
153+
// The regexp pattern or array of patterns that Jest uses to detect test files
154+
// testRegex: [],
155+
156+
// This option allows the use of a custom results processor
157+
// testResultsProcessor: null,
158+
159+
// This option allows use of a custom test runner
160+
testRunner: "jasmine2",
161+
162+
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
163+
testURL: "http://localhost",
164+
165+
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
166+
// timers: "real",
167+
168+
// A map from regular expressions to paths to transformers
169+
// transform: null,
170+
171+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
172+
// transformIgnorePatterns: [
173+
// "/node_modules/"
174+
// ],
175+
176+
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
177+
// unmockedModulePathPatterns: undefined,
178+
179+
// Indicates whether each individual test should be reported during the run
180+
// verbose: null,
181+
182+
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
183+
// watchPathIgnorePatterns: [],
184+
185+
// Whether to use watchman for file crawling
186+
// watchman: true,
187+
};

vue/jest/tsconfig.json

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"compilerOptions": {
3+
/* Basic Options */
4+
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
5+
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
6+
// "lib": [], /* Specify library files to be included in the compilation. */
7+
// "allowJs": true, /* Allow javascript files to be compiled. */
8+
// "checkJs": true, /* Report errors in .js files. */
9+
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
10+
// "declaration": true, /* Generates corresponding '.d.ts' file. */
11+
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
12+
// "sourceMap": true, /* Generates corresponding '.map' file. */
13+
// "outFile": "./", /* Concatenate and emit output to single file. */
14+
// "outDir": "./", /* Redirect output structure to the directory. */
15+
"rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
16+
// "composite": true, /* Enable project compilation */
17+
// "removeComments": true, /* Do not emit comments to output. */
18+
// "noEmit": true, /* Do not emit outputs. */
19+
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
20+
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
21+
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
22+
23+
/* Strict Type-Checking Options */
24+
"strict": true, /* Enable all strict type-checking options. */
25+
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
26+
// "strictNullChecks": true, /* Enable strict null checks. */
27+
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
28+
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
29+
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
30+
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
31+
32+
/* Additional Checks */
33+
// "noUnusedLocals": true, /* Report errors on unused locals. */
34+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
35+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
36+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
37+
38+
/* Module Resolution Options */
39+
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
40+
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
41+
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
42+
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
43+
// "typeRoots": [], /* List of folders to include type definitions from. */
44+
// "types": [], /* Type declaration files to be included in compilation. */
45+
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
46+
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
47+
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
48+
49+
/* Source Map Options */
50+
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
51+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
52+
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
53+
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
54+
55+
/* Experimental Options */
56+
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
57+
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
58+
}
59+
}

0 commit comments

Comments
 (0)