Merge pull request #415 from Gnuk/add-vitest

Add vitest inside TypeScript
This commit is contained in:
Emily Bache 2023-02-22 13:05:43 +01:00 committed by GitHub
commit 2d115146eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 7917 additions and 3861 deletions

View File

@ -1,5 +1,5 @@
import { pathsToModuleNameMapper } from "ts-jest/utils"; import { pathsToModuleNameMapper } from "ts-jest";
const { compilerOptions } = require("./tsconfig"); import { compilerOptions } from './tsconfig.json'
export default { export default {
roots: ['<rootDir>/app', '<rootDir>/test/jest'], roots: ['<rootDir>/app', '<rootDir>/test/jest'],

File diff suppressed because it is too large Load Diff

View File

@ -8,24 +8,28 @@
"pretest": "rimraf app/**/*.js test/**/*.js", "pretest": "rimraf app/**/*.js test/**/*.js",
"test:jest": "jest", "test:jest": "jest",
"test:jest:watch": "jest --watchAll", "test:jest:watch": "jest --watchAll",
"test:mocha": "nyc mocha" "test:mocha": "nyc mocha",
"test:vitest": "vitest --coverage"
}, },
"license": "MIT", "license": "MIT",
"private": true, "private": true,
"devDependencies": { "devDependencies": {
"@types/chai": "^4.2.22", "@types/chai": "^4.2.22",
"@types/jest": "^27.0.2", "@types/jest": "^29.4.0",
"@types/mocha": "^9.0.0", "@types/mocha": "^10.0.1",
"@types/node": "^16.11.7", "@types/node": "^18.14.0",
"@vitest/coverage-istanbul": "^0.28.5",
"chai": "^4.3.4", "chai": "^4.3.4",
"jest": "^27.3.1", "jest": "^29.4.3",
"mocha": "^9.1.3", "mocha": "^10.2.0",
"nyc": "~15.1.0", "nyc": "~15.1.0",
"rimraf": "~3.0.2", "rimraf": "^4.1.2",
"source-map-support": "^0.5.20", "source-map-support": "^0.5.20",
"ts-jest": "^27.0.7", "ts-jest": "^29.0.5",
"ts-node": "^10.4.0", "ts-node": "^10.9.1",
"tsconfig-paths": "^3.11.0", "tsconfig-paths": "^4.1.2",
"typescript": "^4.4.4" "typescript": "^4.4.4",
"vite-tsconfig-paths": "^4.0.5",
"vitest": "^0.28.5"
} }
} }

View File

@ -0,0 +1,9 @@
import { Item, GildedRose } from '@/gilded-rose';
describe('Gilded Rose', () => {
it('should foo', () => {
const gildedRose = new GildedRose([new Item('foo', 0, 0)]);
const items = gildedRose.updateQuality();
expect(items[0].name).toBe('fixme');
});
});

View File

@ -6,6 +6,8 @@
"noImplicitAny": false, "noImplicitAny": false,
"sourceMap": false, "sourceMap": false,
"baseUrl": "./", "baseUrl": "./",
"resolveJsonModule": true,
"esModuleInterop": true,
"paths": { "paths": {
"@/*": [ "@/*": [
"app/*" "app/*"

View File

@ -0,0 +1,14 @@
import {defineConfig} from 'vitest/config';
import tsconfigPaths from 'vite-tsconfig-paths';
export default defineConfig({
plugins: [tsconfigPaths()],
test: {
globals: true,
include: ['test/vitest/**/*.{spec,test}.{js,ts}'],
coverage: {
provider: 'istanbul',
reporter: ['text', 'html']
}
},
});