Skip to content

Commit

Permalink
Set up ts jest
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Poupin committed Jul 8, 2018
1 parent afe7cac commit d3fb487
Show file tree
Hide file tree
Showing 7 changed files with 399 additions and 21 deletions.
22 changes: 21 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"scripts": {
"build": "webpack -p",
"start": "webpack-dev-server",
"test": "jest",
"deploy": "yarn build && gh-pages -d dist"
},
"dependencies": {
Expand All @@ -12,17 +13,36 @@
"phaser": "3.10.1"
},
"devDependencies": {
"@types/jest": "23.1.4",
"@types/node": "10.5.2",
"babel-core": "^6.26.3",
"babel-jest": "^23.2.0",
"copy-webpack-plugin": "4.5.1",
"jest": "23.3.0",
"source-map-loader": "^0.2.3",
"ts-jest": "23.0.0",
"typescript": "^2.9.2",
"webpack": "4.10.2",
"webpack-cli": "3.0.2",
"webpack-dev-server": "3.1.4"
},
"jest": {
"moduleFileExtensions": [
"ts",
"tsx",
"json",
"js"
],
"transform": {
"^.+\\.(ts|tsx)$": "ts-jest"
},
"globals": {
"ts-jest": {
"tsConfigFile": "tsconfig.json"
}
},
"testMatch": [
"**/tests/**/*.js"
"**/tests/**/*.ts"
]
}
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference path="../typings/phaser.d.ts" />
/// <reference path="../typings/typings.d.ts" />

import 'phaser';
import Main from './scenes/Main';
Expand Down
10 changes: 0 additions & 10 deletions tests/map.js

This file was deleted.

13 changes: 13 additions & 0 deletions tests/map.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const maps = require('../src/constants/maps').default;

describe('map', () => {
Object.keys(maps).map(mapInfoKey => {
const map = require(`../assets/${maps[mapInfoKey].file}`);
describe(mapInfoKey, () => {
it('should have the proper layers', () => {
const hasTerrain = map.layers.find(o => o.name === 'terrain');
expect(hasTerrain).toBeDefined();
});
});
});
});
5 changes: 5 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
"lib": ["es2017", "dom"],
"sourceMap": true
},
"jest": {
"globals": {
"require": true
}
},
"include": ["./src/**/*"],
"exclude": ["node_modules", "bin", "typings/phaser.d.ts"]
}
4 changes: 4 additions & 0 deletions typings/typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module '*.json' {
const value: any;
export default value;
}
Loading

0 comments on commit d3fb487

Please sign in to comment.