mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-12 04:12:13 +00:00
Get the TypeScript TextTests working more conveniently
This commit is contained in:
parent
3fb6c60ad1
commit
fa5ea72fd2
@ -10,23 +10,9 @@ Install dependencies
|
|||||||
npm install
|
npm install
|
||||||
```
|
```
|
||||||
|
|
||||||
## Running app
|
## Run the unit tests from the Command-Line
|
||||||
_You may need to install `ts-node`_
|
|
||||||
|
|
||||||
```sh
|
There are two unit test frameworks to choose from, Jest and Mocha.
|
||||||
npx ts-node test/golden-master-text-test.ts
|
|
||||||
```
|
|
||||||
|
|
||||||
Or with number of days as args:
|
|
||||||
```sh
|
|
||||||
npx ts-node test/golden-master-text-test.ts 10
|
|
||||||
```
|
|
||||||
|
|
||||||
## Running tests
|
|
||||||
|
|
||||||
To run all tests
|
|
||||||
|
|
||||||
### Jest way
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm run test:jest
|
npm run test:jest
|
||||||
@ -38,8 +24,34 @@ To run all tests in watch mode
|
|||||||
npm run test:jest:watch
|
npm run test:jest:watch
|
||||||
```
|
```
|
||||||
|
|
||||||
### Mocha way
|
Mocha
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm run test:mocha
|
npm run test:mocha
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Run the TextTest fixture from the Command-Line
|
||||||
|
|
||||||
|
_You may need to install `ts-node`_
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npx ts-node test/golden-master-text-test.ts
|
||||||
|
```
|
||||||
|
|
||||||
|
Or with number of days as args:
|
||||||
|
```sh
|
||||||
|
npx ts-node test/golden-master-text-test.ts 10
|
||||||
|
```
|
||||||
|
|
||||||
|
You should make sure the command shown above works when you execute it in a terminal before trying to use TextTest (see below).
|
||||||
|
|
||||||
|
|
||||||
|
## Run the TextTest approval test that comes with this project
|
||||||
|
|
||||||
|
There are instructions in the [TextTest Readme](../texttests/README.md) for setting up TextTest. You will need to specify the Python executable and interpreter in [config.gr](../texttests/config.gr). Uncomment these lines:
|
||||||
|
|
||||||
|
executable:${TEXTTEST_HOME}/python/texttest_fixture.py
|
||||||
|
interpreter:python
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
import { Item, GildedRose } from '../app/gilded-rose';
|
import { Item, GildedRose } from '../app/gilded-rose';
|
||||||
|
|
||||||
|
console.log("OMGHAI!")
|
||||||
|
|
||||||
const items = [
|
const items = [
|
||||||
new Item("+5 Dexterity Vest", 10, 20), //
|
new Item("+5 Dexterity Vest", 10, 20), //
|
||||||
new Item("Aged Brie", 2, 0), //
|
new Item("Aged Brie", 2, 0), //
|
||||||
@ -20,11 +22,11 @@ if (process.argv.length > 2) {
|
|||||||
days = +process.argv[2];
|
days = +process.argv[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < days; i++) {
|
for (let i = 0; i < days + 1; i++) {
|
||||||
console.log("-------- day " + i + " --------");
|
console.log("-------- day " + i + " --------");
|
||||||
console.log("name, sellIn, quality");
|
console.log("name, sellIn, quality");
|
||||||
items.forEach(element => {
|
items.forEach(element => {
|
||||||
console.log(element.name + ' ' + element.sellIn + ' ' + element.quality);
|
console.log(element.name + ', ' + element.sellIn + ', ' + element.quality);
|
||||||
|
|
||||||
});
|
});
|
||||||
console.log();
|
console.log();
|
||||||
|
|||||||
14
TypeScript/texttest_rig.py
Normal file
14
TypeScript/texttest_rig.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
"""
|
||||||
|
This script uses npx to execute the TextTest Fixture for TypeScript.
|
||||||
|
It is designed to be used by TextTest and specified in the file 'texttests/config.gr' in this repo.
|
||||||
|
It is more convenient for TextTest to use since npx needs
|
||||||
|
several arguments in addition to the one the TextTest fixture needs.
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
args = " ".join(sys.argv[1:])
|
||||||
|
TEXTTEST_HOME = os.environ.get("TEXTTEST_HOME", os.getcwd())
|
||||||
|
subprocess.run(f"npx ts-node {TEXTTEST_HOME}/TypeScript/test/golden-master-text-test.ts {args}", shell=True)
|
||||||
@ -32,8 +32,8 @@ diff_program:meld
|
|||||||
#interpreter:perl
|
#interpreter:perl
|
||||||
|
|
||||||
# Settings for the TypeScript version
|
# Settings for the TypeScript version
|
||||||
#executable:${TEXTTEST_HOME}/TypeScript/test/golden-master-text-test.js
|
#executable:${TEXTTEST_HOME}/TypeScript/texttest_rig.py
|
||||||
#interpreter:node
|
#interpreter:python
|
||||||
|
|
||||||
# Settings for the Julia version
|
# Settings for the Julia version
|
||||||
#executable:${TEXTTEST_HOME}/julia/texttest_fixture.jl
|
#executable:${TEXTTEST_HOME}/julia/texttest_fixture.jl
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user