1
0

Use node assertions as standard solution

This commit is contained in:
2025-07-16 16:39:09 +02:00
parent ef41c7d788
commit decd8e9e3d
18 changed files with 1789 additions and 6069 deletions

View File

@@ -1,5 +1,5 @@
import { Given, When, Then } from '@cucumber/cucumber' import { Given, When, Then } from '@cucumber/cucumber'
import { expect } from 'chai' import assert from 'node:assert/strict'
import axios from 'axios' import axios from 'axios'
When('I request the same resource three times', function () { When('I request the same resource three times', function () {
@@ -20,10 +20,10 @@ When('I request the same resource three times', function () {
}) })
Then('the responses should be the same', function () { Then('the responses should be the same', function () {
expect(this.first).to.equal(this.second) assert.equal(this.first, this.second)
if (this.third === undefined) { if (this.third === undefined) {
return return
} }
expect(this.second).to.equal(this.third) assert.equal(this.second, this.third)
}) })

View File

@@ -1,16 +1,13 @@
import { BeforeAll, AfterAll } from '@cucumber/cucumber' import { BeforeAll, AfterAll } from '@cucumber/cucumber'
import express from 'express' import { createServer } from 'node:http'
let server let server
BeforeAll(function () { BeforeAll(function () {
const app = express() server = createServer(function (request, response) {
response.end('Alea iacta est')
app.get('/', (req, res) => {
res.send('Alea iacta est')
}) })
server.listen(8080)
server = app.listen(8080)
}) })
AfterAll(function () { AfterAll(function () {

1777
async/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -10,9 +10,7 @@
"author": "Eugen Wissner <belka@caraus.de>", "author": "Eugen Wissner <belka@caraus.de>",
"license": "MPL-2.0", "license": "MPL-2.0",
"dependencies": { "dependencies": {
"@cucumber/cucumber": "^11.1.1", "@cucumber/cucumber": "^12.0.0",
"axios": "^1.7.9", "axios": "^1.7.9"
"chai": "^5.1.2",
"express": "^4.16.4"
} }
} }

View File

@@ -1,5 +1,5 @@
import { Given, When, Then } from '@cucumber/cucumber' import { Given, When, Then } from '@cucumber/cucumber'
import { expect } from 'chai' import assert from 'node:assert/strict'
Given('the following books by Simon Frank are in the collection:', function (dataTable) { Given('the following books by Simon Frank are in the collection:', function (dataTable) {
this.objects = [] this.objects = []
@@ -45,6 +45,5 @@ When('I stringify it', function () {
}) })
Then('I should get:', function (expected) { Then('I should get:', function (expected) {
expect(JSON.parse(expected)) assert.deepEqual(JSON.parse(expected), JSON.parse(this.result))
.to.deep.equal(JSON.parse(this.result))
}) })

File diff suppressed because it is too large Load Diff

View File

@@ -10,7 +10,6 @@
"author": "Eugen Wissner <belka@caraus.de>", "author": "Eugen Wissner <belka@caraus.de>",
"license": "MPL-2.0", "license": "MPL-2.0",
"dependencies": { "dependencies": {
"@cucumber/cucumber": "^11.1.1", "@cucumber/cucumber": "^12.0.0"
"chai": "^5.1.2"
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -11,6 +11,6 @@
"author": "Eugen Wissner <belka@caraus.de>", "author": "Eugen Wissner <belka@caraus.de>",
"license": "MPL-2.0", "license": "MPL-2.0",
"dependencies": { "dependencies": {
"@cucumber/cucumber": "^11.1.1" "@cucumber/cucumber": "^12.0.0"
} }
} }

View File

@@ -1,6 +1,6 @@
import { Before, Given, Then } from '@cucumber/cucumber' import { Before, Given, Then } from '@cucumber/cucumber'
import { expect } from 'chai' import { expect } from 'chai'
import R from 'ramda' import * as R from 'ramda'
function step (name) { function step (name) {
this.names.push(name) this.names.push(name)

1174
reuse/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -13,8 +13,8 @@
"chai": "^5.1.2" "chai": "^5.1.2"
}, },
"dependencies": { "dependencies": {
"@cucumber/cucumber": "^11.1.1", "@cucumber/cucumber": "^12.0.0",
"lodash": "^4.17.11", "lodash": "^4.17.11",
"ramda": "^0.30.1" "ramda": "^0.31.3"
} }
} }

View File

@@ -1,10 +1,10 @@
import { When, Then } from '@cucumber/cucumber'; import { When, Then } from '@cucumber/cucumber';
import { expect } from 'chai'; import assert from 'node:assert/strict';
When('the step definitions are written in {word}', function (language: string) { When('the step definitions are written in {word}', function (language: string) {
this.language = language; this.language = language;
}); });
Then("I don't get a warning about undefined steps", function () { Then("I don't get a warning about undefined steps", function () {
expect(this.language).to.equal('TypeScript'); assert.equal(this.language, 'TypeScript');
}); });

1253
ts/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -10,12 +10,8 @@
"author": "Eugen Wissner <belka@caraus.de>", "author": "Eugen Wissner <belka@caraus.de>",
"license": "MPL-2.0", "license": "MPL-2.0",
"dependencies": { "dependencies": {
"@cucumber/cucumber": "^11.1.1", "@cucumber/cucumber": "^12.0.0",
"chai": "^5.1.2",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "^5.7.2" "typescript": "^5.7.2"
},
"devDependencies": {
"@types/chai": "^5.0.1"
} }
} }

View File

@@ -1,5 +1,5 @@
import { Before, Given, When, Then, defineParameterType } from '@cucumber/cucumber' import { Before, Given, When, Then, defineParameterType } from '@cucumber/cucumber'
import { expect } from 'chai' import assert from 'node:assert/strict'
defineParameterType({ defineParameterType({
name: 'tobe', name: 'tobe',
@@ -14,11 +14,11 @@ When('I interpret "to be" as a type', function () {
}) })
Then('true {tobe} true', function (predicate) { Then('true {tobe} true', function (predicate) {
expect(predicate).to.be.true assert(predicate)
}) })
Then('false {tobe} true', function (predicate) { Then('false {tobe} true', function (predicate) {
expect(predicate).to.be.false assert(!predicate)
}) })
defineParameterType({ defineParameterType({
@@ -32,7 +32,7 @@ When('a date {date} is given', function (dateString) {
}) })
Then('it gets converted to a Date object', function () { Then('it gets converted to a Date object', function () {
expect(this.date).to.be.an.instanceof(Date) assert(this.date instanceof Date)
}) })
Before(function () { Before(function () {
@@ -44,5 +44,5 @@ Given(/(a regular expression|it) matches (this|that) pattern/, function (_x, _y)
}) })
Then('the step definition should be called twice', function () { Then('the step definition should be called twice', function () {
expect(this.count).to.equal(2) assert.equal(this.count, 2)
}) })

File diff suppressed because it is too large Load Diff

View File

@@ -9,10 +9,7 @@
}, },
"author": "Eugen Wissner <belka@caraus.de>", "author": "Eugen Wissner <belka@caraus.de>",
"license": "MPL-2.0", "license": "MPL-2.0",
"devDependencies": {
"chai": "^5.1.2"
},
"dependencies": { "dependencies": {
"@cucumber/cucumber": "^11.1.1" "@cucumber/cucumber": "^12.0.0"
} }
} }