From 9c25e720ad7b6d7d1c750b88f6f6ea909202b356 Mon Sep 17 00:00:00 2001 From: Skyler Kehren Date: Wed, 26 Feb 2020 08:02:12 +0200 Subject: [PATCH 1/3] Cleanup integration testing docs Removes `test-integration` script Removes integration from `test` script Add installation instructions for `screeps-server-mockup` in docs --- README.md | 4 +--- docs/in-depth/testing.md | 24 +++++++++++++++++++++++- package.json | 3 +-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e00e06be6..b28fc33c6 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,7 @@ You will need: - [Node.JS](https://nodejs.org/en/download) (>= 8.0.0) - A Package Manager ([Yarn](https://yarnpkg.com/en/docs/getting-started) or [npm](https://docs.npmjs.com/getting-started/installing-node)) - - Rollup CLI (Optional, install via `npm install -g rollup`) - - Build tools (`apt install build-essential` for Ubuntu, [Visual Studio](https://www.visualstudio.com/vs/) for Windows, etc) - + - Rollup CLI (Optional, install via `npm install -g rollup`) Download the latest source [here](https://github.com/screepers/screeps-typescript-starter/archive/master.zip) and extract it to a folder. diff --git a/docs/in-depth/testing.md b/docs/in-depth/testing.md index 37582b962..3de0d158d 100644 --- a/docs/in-depth/testing.md +++ b/docs/in-depth/testing.md @@ -42,13 +42,35 @@ magnitude, it is recommended to prefer unit tests wherever possible. ## Integration Testing +### Installing Screeps Server Mockup + +Before starting to use integration testing, you must install [screeps-server-mockup](https://github.com/screepers/screeps-server-mockup) to your project. +Please view that repository for more instruction on installation. + +You will also need to add scripts to run integration tests. + +In `package.json`, add a new `test-integration` script and add the new integration testing to the main `test` script. + +```json + "scripts": { + ... + "test": "npm run test-unit && npm run test-integration", + "test-integration": "npm run build && rollup -c rollup.test-integration-config.js && mocha dist/test-integration.bundle.js", + ... + } +``` + +Now you can run integration tests by using the `test-integration` script or run both unit and integration tests using the `test` script. + +### Integration Testing with Screeps Server Mockup + Integration testing is for code that depends heavily on having a full game environment. Integration tests are completely representative of the real game (in fact they run with an actual Screeps server). This comes at the cost of performance and very involved setup when creating specific scenarios. Server testing support is implmented via -[screeps-server-mockup](https://github.com/Hiryus/screeps-server-mockup). View +[screeps-server-mockup](https://github.com/screepers/screeps-server-mockup). View this repository for more information on the API. By default the test helper will create a "stub" world with a 3x3 grid of rooms diff --git a/package.json b/package.json index 9f61cab5a..40bc81343 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,8 @@ "push-main": "rollup -c --environment DEST:main", "push-pserver": "rollup -c --environment DEST:pserver", "push-sim": "rollup -c --environment DEST:sim", - "test": "npm run test-unit && npm run test-integration", + "test": "npm run test-unit", "test-unit": "rollup -c rollup.test-unit-config.js && mocha dist/test-unit.bundle.js", - "test-integration": "npm run build && rollup -c rollup.test-integration-config.js && mocha dist/test-integration.bundle.js", "watch-main": "rollup -cw --environment DEST:main", "watch-pserver": "rollup -cw --environment DEST:pserver", "watch-sim": "rollup -cw --environment DEST:sim" From de4b19b2deae537a1b485ce320a10b965c6f78d0 Mon Sep 17 00:00:00 2001 From: Skyler Kehren Date: Wed, 26 Feb 2020 08:07:17 +0200 Subject: [PATCH 2/3] Fix codeblock formatting --- docs/in-depth/testing.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/in-depth/testing.md b/docs/in-depth/testing.md index 3de0d158d..2d2f03331 100644 --- a/docs/in-depth/testing.md +++ b/docs/in-depth/testing.md @@ -53,10 +53,8 @@ In `package.json`, add a new `test-integration` script and add the new integrati ```json "scripts": { - ... "test": "npm run test-unit && npm run test-integration", "test-integration": "npm run build && rollup -c rollup.test-integration-config.js && mocha dist/test-integration.bundle.js", - ... } ``` From b3d7bda215d1b3de14f9ae7d370b58d1c9797a1b Mon Sep 17 00:00:00 2001 From: Skyler Kehren Date: Sat, 2 May 2020 12:51:58 +0300 Subject: [PATCH 3/3] Fixing PR review comments Adds direct example for installing screeps-server-mockup Adds test-integration script that prints where to find more info Fixes typo in integration: testing docs --- docs/in-depth/testing.md | 9 ++++++++- package.json | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/in-depth/testing.md b/docs/in-depth/testing.md index 2d2f03331..a115e825c 100644 --- a/docs/in-depth/testing.md +++ b/docs/in-depth/testing.md @@ -47,6 +47,13 @@ magnitude, it is recommended to prefer unit tests wherever possible. Before starting to use integration testing, you must install [screeps-server-mockup](https://github.com/screepers/screeps-server-mockup) to your project. Please view that repository for more instruction on installation. +```bash +# Using yarn: +yarn add -D screeps-server-mockup +# Using npm +npm install --save-dev screeps-server-mockup +``` + You will also need to add scripts to run integration tests. In `package.json`, add a new `test-integration` script and add the new integration testing to the main `test` script. @@ -67,7 +74,7 @@ environment. Integration tests are completely representative of the real game (in fact they run with an actual Screeps server). This comes at the cost of performance and very involved setup when creating specific scenarios. -Server testing support is implmented via +Server testing support is implemented via [screeps-server-mockup](https://github.com/screepers/screeps-server-mockup). View this repository for more information on the API. diff --git a/package.json b/package.json index 40bc81343..93484852d 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "push-sim": "rollup -c --environment DEST:sim", "test": "npm run test-unit", "test-unit": "rollup -c rollup.test-unit-config.js && mocha dist/test-unit.bundle.js", + "test-integration": "echo 'See docs/in-depth/testing.md for instructions on enabling integration tests'", "watch-main": "rollup -cw --environment DEST:main", "watch-pserver": "rollup -cw --environment DEST:pserver", "watch-sim": "rollup -cw --environment DEST:sim"