Update Jest to use Babel for export support in packages

rpg-dice-roller strikes again, with ES6 and ts-jest. Using Babel with TypeScript resolves the issue.
This commit is contained in:
James Skemp 2020-08-03 00:16:40 -05:00
parent a0d16705e6
commit 27aa36fc01
5 changed files with 979 additions and 62 deletions

View File

@ -0,0 +1,14 @@
import World from "@/models/World";
import { startNextMoment } from '@/utilities/WorldUtilities';
const world = new World();
test('World starts at moment 0', () => {
expect(world.currentMoment).toBe(0);
});
test('Starting next moment increments moment by 1', () => {
const startMoment = world.currentMoment;
startNextMoment(world);
expect(world.currentMoment).toBe(startMoment + 1);
});

6
babel.config.js Normal file
View File

@ -0,0 +1,6 @@
module.exports = {
presets: [
['@babel/preset-env', {targets: {node: 'current'}}],
'@babel/preset-typescript',
]
}

View File

@ -1,26 +1,28 @@
const modulesWithExport = ['rpg-dice-roller'].join('|');
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
roots: [
'<rootDir>'
'<rootDir>/src',
'<rootDir>/__tests__'
],
modulePaths: [
'<rootDir>'
],
// An array of glob patterns indicating a set of files for which coverage information should be collected
collectCoverageFrom: [
"<rootDir>/src/**/*.ts",
"!<rootDir>/src/**/*.d.ts"
"<rootDir>/src/**/*.ts",
// Exclude Vue.js main file.
"!<rootDir>/src/main.ts",
"!<rootDir>/src/**/*.d.ts",
'!**/node_modules/**',
],
transformIgnorePatterns: [
`/node_modules/(?!${modulesWithExport})`
],
// The directory where Jest should output its coverage files
//coverageDirectory: "coverage",
/*moduleNameMapper: {
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1'
},*/
globals: {
'ts-jest': {
}
}
};

991
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,8 @@
"eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx,.vue || (exit 0)",
"docs": "typedoc --out docs src && http-server docs",
"test": "jest",
"test:coverage": "jest --coverage"
"test:coverage": "jest --coverage",
"test:coverageWatch": "jest --coverage --watchAll"
},
"dependencies": {
"@vue/eslint-config-typescript": "^5.0.2",
@ -21,17 +22,20 @@
"vue-property-decorator": "^9.0.0"
},
"devDependencies": {
"@babel/core": "^7.11.0",
"@babel/preset-env": "^7.11.0",
"@babel/preset-typescript": "^7.10.4",
"@types/jest": "^26.0.8",
"@typescript-eslint/eslint-plugin": "^3.7.1",
"@typescript-eslint/parser": "^3.7.1",
"@vue/cli-plugin-eslint": "^4.4.6",
"@vue/cli-plugin-typescript": "^4.4.6",
"@vue/cli-service": "^4.4.6",
"babel-jest": "^26.2.2",
"eslint": "^7.5.0",
"eslint-plugin-jsdoc": "^30.0.3",
"eslint-plugin-vue": "^6.1.2",
"jest": "^26.2.2",
"ts-jest": "^26.1.4",
"typescript": "^3.9.7",
"vue-template-compiler": "^2.6.11"
}