Get texttests working for Javascript-Jest

This commit is contained in:
emily 2023-11-03 15:36:54 +01:00
parent 6df86da845
commit c1638a56b8
4 changed files with 29 additions and 7 deletions

View File

@ -1,6 +1,4 @@
# Gilded Rose # Gilded Rose in Javascript with Jest
This is the Gilded Rose kata in JavaScript with Jest
## Getting started ## Getting started
@ -10,7 +8,7 @@ Install dependencies
npm install npm install
``` ```
## Running tests ## Run the unit tests from the Command-Line
To run all tests To run all tests
@ -29,3 +27,21 @@ To generate test coverage report
```sh ```sh
npm run test:coverage npm run test:coverage
``` ```
## Run the TextTest fixture from the Command-Line
For e.g. 10 days:
```
node test/texttest_fixture.js 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 Javascript-Jest executable and interpreter in [config.gr](../texttests/config.gr). Uncomment these lines:
executable:${TEXTTEST_HOME}/js-jest/test/texttest_fixture.js
interpreter:node

View File

@ -5,7 +5,8 @@
"scripts": { "scripts": {
"test": "jest", "test": "jest",
"test:watch": "jest --watch", "test:watch": "jest --watch",
"test:coverage": "jest --coverage" "test:coverage": "jest --coverage",
"texttest": "node test/texttest_fixture.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -19,9 +19,10 @@ const days = Number(process.argv[2]) || 2;
const gildedRose = new Shop(items); const gildedRose = new Shop(items);
console.log("OMGHAI!"); console.log("OMGHAI!");
for (let day = 0; day < days; day++) { for (let day = 0; day < days + 1; day++) {
console.log(`\n-------- day ${day} --------`); console.log(`-------- day ${day} --------`);
console.log("name, sellIn, quality"); console.log("name, sellIn, quality");
items.forEach(item => console.log(`${item.name}, ${item.sellIn}, ${item.quality}`)); items.forEach(item => console.log(`${item.name}, ${item.sellIn}, ${item.quality}`));
gildedRose.updateQuality(); gildedRose.updateQuality();
console.log("")
} }

View File

@ -35,6 +35,10 @@ diff_program:meld
#executable:${TEXTTEST_HOME}/TypeScript/texttest_rig.py #executable:${TEXTTEST_HOME}/TypeScript/texttest_rig.py
#interpreter:python #interpreter:python
# Settings for the Javascript Jest version
executable:${TEXTTEST_HOME}/js-jest/test/texttest_fixture.js
interpreter:node
# Settings for the Julia version # Settings for the Julia version
#executable:${TEXTTEST_HOME}/julia/texttest_fixture.jl #executable:${TEXTTEST_HOME}/julia/texttest_fixture.jl
#interpreter:julia #interpreter:julia