From f86245febbfebb9eeb9735438932e0f664093b4e Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Tue, 16 Oct 2018 03:31:27 -0500 Subject: [PATCH] Add mocha tests to `npm test` --- .eslintignore | 1 + build-tools/update | 3 --- package.json | 2 +- test/battle-test.mocha.js | 11 +++++++---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.eslintignore b/.eslintignore index 4ed753b5f..5ca096b50 100644 --- a/.eslintignore +++ b/.eslintignore @@ -7,4 +7,5 @@ node_modules/ /js/battle-dex.js /js/battle-dex-data.js /js/battle-animations-moves.js +/js/battle-scene-stub.js /js/battle-animations.js diff --git a/build-tools/update b/build-tools/update index 30d40fdb1..744d6b1e1 100755 --- a/build-tools/update +++ b/build-tools/update @@ -4,9 +4,6 @@ * This script parses index.html and sets the version query string of each * resource to be the MD5 hash of that resource. * It also updates news and the learnsets-g6.js file. - * - * On the live web server, this script is set as the following git hooks: - * post-commit, post-checkout, post-merge, post-rewrite */ "use strict"; diff --git a/package.json b/package.json index 17e9a53c4..5e97afbff 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "url": "https://github.com/Zarel/Pokemon-Showdown-Client.git" }, "scripts": { - "test": "eslint --config=.eslintrc.js --cache --cache-file=eslint-cache/base js/ && eslint --config=build-tools/.eslintrc.js --cache --cache-file=eslint-cache/build build-tools/update build-tools/build-indexes", + "test": "eslint --config=.eslintrc.js --cache --cache-file=eslint-cache/base js/ && eslint --config=build-tools/.eslintrc.js --cache --cache-file=eslint-cache/build build-tools/update build-tools/build-indexes && node build && mocha", "fix": "eslint --config=.eslintrc.js --fix js/ && eslint --config=build-tools/.eslintrc.js --fix build-tools/update build-tools/build-indexes" }, "dependencies": { diff --git a/test/battle-test.mocha.js b/test/battle-test.mocha.js index 7f482cca0..964be3237 100644 --- a/test/battle-test.mocha.js +++ b/test/battle-test.mocha.js @@ -1,13 +1,16 @@ const fs = require('fs'); +const path = require('path'); const assert = require('assert').strict; +process.chdir(path.resolve(__dirname, '..')); + window = global; // Without making these modules, the best we can do is directly include them into this workspace. -eval('' + fs.readFileSync(`${__dirname}/../js/battle-scene-stub.js`)); -eval('' + fs.readFileSync(`${__dirname}/../js/battle-dex.js`)); -eval('' + fs.readFileSync(`${__dirname}/../js/battle-dex-data.js`)); -eval('' + fs.readFileSync(`${__dirname}/../js/battle.js`)); +eval('' + fs.readFileSync(`js/battle-scene-stub.js`)); +eval('' + fs.readFileSync(`js/battle-dex.js`)); +eval('' + fs.readFileSync(`js/battle-dex-data.js`)); +eval('' + fs.readFileSync(`js/battle.js`)); describe('Battle', function () {