Skip to content

Commit

Permalink
build: bump cucumber library dependencies to latest (#1510)
Browse files Browse the repository at this point in the history
* bump cucumber libraries

* more updates

* Update more dependencies

* Update html-formatter and query

* Fix typescript compilation error

* Reformat code: npm run lint-autofix

* Fix typescript compilation

* Fix typescript compilation

* html formatter bump

* html formatter bump

* missed lockfile change

Co-authored-by: Aslak Hellesøy <aslak.hellesoy@smartbear.com>
  • Loading branch information
davidjgoss and aslakhellesoy committed Dec 18, 2020
1 parent 3975db7 commit 7fd71e1
Show file tree
Hide file tree
Showing 16 changed files with 978 additions and 711 deletions.
78 changes: 37 additions & 41 deletions compatibility/features/attachments/attachments.ts
Expand Up @@ -5,57 +5,53 @@ import path from 'path'

Before((): void => undefined)

When('the string {string} is attached as {string}', async function (
this: World,
text: string,
mediaType: string
) {
await this.attach(text, mediaType)
})
When(
'the string {string} is attached as {string}',
async function (this: World, text: string, mediaType: string) {
await this.attach(text, mediaType)
}
)

When('the string {string} is logged', async function (
this: World,
text: string
) {
await this.log(text)
})
When(
'the string {string} is logged',
async function (this: World, text: string) {
await this.log(text)
}
)

When('text with ANSI escapes is logged', async function (this: World) {
await this.log(
'This displays a \x1b[31mr\x1b[0m\x1b[91ma\x1b[0m\x1b[33mi\x1b[0m\x1b[32mn\x1b[0m\x1b[34mb\x1b[0m\x1b[95mo\x1b[0m\x1b[35mw\x1b[0m'
)
})

When('the following string is attached as {string}:', async function (
this: World,
mediaType: string,
text: string
) {
await this.attach(text, mediaType)
})
When(
'the following string is attached as {string}:',
async function (this: World, mediaType: string, text: string) {
await this.attach(text, mediaType)
}
)

When('an array with {int} bytes is attached as {string}', async function (
this: World,
size: number,
mediaType: string
) {
const data = [...Array(size).keys()]
const buffer = Buffer.from(data)
await this.attach(buffer, mediaType)
})
When(
'an array with {int} bytes is attached as {string}',
async function (this: World, size: number, mediaType: string) {
const data = [...Array(size).keys()]
const buffer = Buffer.from(data)
await this.attach(buffer, mediaType)
}
)

When('a stream with {int} bytes are attached as {string}', async function (
this: World,
size: number,
mediaType: string
) {
const data = [...Array(size).keys()]
const buffer = Buffer.from(data)
const stream = new ReadableStreamBuffer({ chunkSize: 1, frequency: 1 })
stream.put(buffer)
stream.stop()
await this.attach(stream, mediaType)
})
When(
'a stream with {int} bytes are attached as {string}',
async function (this: World, size: number, mediaType: string) {
const data = [...Array(size).keys()]
const buffer = Buffer.from(data)
const stream = new ReadableStreamBuffer({ chunkSize: 1, frequency: 1 })
stream.put(buffer)
stream.stop()
await this.attach(stream, mediaType)
}
)

When('a JPEG image is attached', async function (this: World) {
await this.attach(
Expand Down
12 changes: 6 additions & 6 deletions compatibility/features/data-tables/data-tables.ts
@@ -1,12 +1,12 @@
import { When, Then, DataTable } from '../../..'
import { expect } from 'chai'

When('the following table is transposed:', function (
this: any,
table: DataTable
) {
this.transposed = table.transpose()
})
When(
'the following table is transposed:',
function (this: any, table: DataTable) {
this.transposed = table.transpose()
}
)

Then('it should be:', function (this: any, expected: DataTable) {
expect(this.transposed.raw()).to.deep.eq(expected.raw())
Expand Down
12 changes: 6 additions & 6 deletions compatibility/features/examples-tables/examples-tables.ts
Expand Up @@ -9,9 +9,9 @@ When('I eat {int} cucumbers', function (this: any, eatCount: number) {
this.count -= eatCount
})

Then('I should have {int} cucumbers', function (
this: any,
expectedCount: number
) {
assert.strictEqual(this.count, expectedCount)
})
Then(
'I should have {int} cucumbers',
function (this: any, expectedCount: number) {
assert.strictEqual(this.count, expectedCount)
}
)
14 changes: 7 additions & 7 deletions compatibility/features/parameter-types/parameter-types.ts
Expand Up @@ -13,10 +13,10 @@ defineParameterType({
},
})

Given('{flight} has been delayed {int} minutes', function (
flight: Flight,
delay: number
) {
expect(flight.from).to.eq('LHR')
expect(flight.to).to.eq('CDG')
})
Given(
'{flight} has been delayed {int} minutes',
function (flight: Flight, delay: number) {
expect(flight.from).to.eq('LHR')
expect(flight.to).to.eq('CDG')
}
)
32 changes: 16 additions & 16 deletions compatibility/features/rules/rules.ts
@@ -1,14 +1,14 @@
import assert from 'assert'
import { Given, When, Then } from '../../..'

Given('there are {int} {float} coins inside', function (
count: number,
denomination: number
) {
// TODO: implement this
assert(count)
assert(denomination)
})
Given(
'there are {int} {float} coins inside',
function (count: number, denomination: number) {
// TODO: implement this
assert(count)
assert(denomination)
}
)

Given('there are no chocolates inside', function () {
// TODO: implement this
Expand All @@ -32,11 +32,11 @@ Then('the sale should not happen', function () {
// TODO: implement this
})

Then("the customer's change should be {int} {float} coin(s)", function (
count: number,
denomination: number
) {
// TODO: implement this
assert(count)
assert(denomination)
})
Then(
"the customer's change should be {int} {float} coin(s)",
function (count: number, denomination: number) {
// TODO: implement this
assert(count)
assert(denomination)
}
)
68 changes: 34 additions & 34 deletions features/step_definitions/cli_steps.ts
Expand Up @@ -86,43 +86,43 @@ Then(/^the output contains the text:$/, function (this: World, text: string) {
expect(actualOutput).to.include(expectedOutput)
})

Then('the output does not contain the text:', function (
this: World,
text: string
) {
const actualOutput = normalizeText(this.lastRun.output)
const expectedOutput = normalizeText(text)
expect(actualOutput).not.to.include(expectedOutput)
})
Then(
'the output does not contain the text:',
function (this: World, text: string) {
const actualOutput = normalizeText(this.lastRun.output)
const expectedOutput = normalizeText(text)
expect(actualOutput).not.to.include(expectedOutput)
}
)

Then(/^the error output contains the text snippets:$/, function (
this: World,
table: DataTable
) {
const actualOutput = normalizeText(this.lastRun.errorOutput)
table.rows().forEach((row) => {
const expectedOutput = normalizeText(row[0])
expect(actualOutput).to.include(expectedOutput)
})
})
Then(
/^the error output contains the text snippets:$/,
function (this: World, table: DataTable) {
const actualOutput = normalizeText(this.lastRun.errorOutput)
table.rows().forEach((row) => {
const expectedOutput = normalizeText(row[0])
expect(actualOutput).to.include(expectedOutput)
})
}
)

Then(/^the error output contains the text:$/, function (
this: World,
text: string
) {
const actualOutput = normalizeText(this.lastRun.errorOutput)
const expectedOutput = normalizeText(text)
expect(actualOutput).to.include(expectedOutput)
})
Then(
/^the error output contains the text:$/,
function (this: World, text: string) {
const actualOutput = normalizeText(this.lastRun.errorOutput)
const expectedOutput = normalizeText(text)
expect(actualOutput).to.include(expectedOutput)
}
)

Then('the error output does not contain the text:', function (
this: World,
text: string
) {
const actualOutput = normalizeText(this.lastRun.errorOutput)
const expectedOutput = normalizeText(text)
expect(actualOutput).not.to.include(expectedOutput)
})
Then(
'the error output does not contain the text:',
function (this: World, text: string) {
const actualOutput = normalizeText(this.lastRun.errorOutput)
const expectedOutput = normalizeText(text)
expect(actualOutput).not.to.include(expectedOutput)
}
)

Then(/^I see the version of Cucumber$/, function (this: World) {
const actualOutput = this.lastRun.output
Expand Down
84 changes: 41 additions & 43 deletions features/step_definitions/file_steps.ts
Expand Up @@ -7,51 +7,49 @@ import path from 'path'
import Mustache from 'mustache'
import { World } from '../support/world'

Given(/^a file named "(.*)" with:$/, async function (
this: World,
filePath: string,
fileContent: string
) {
const absoluteFilePath = path.join(this.tmpDir, filePath)
if (filePath === '@rerun.txt') {
fileContent = fileContent.replace(/\//g, path.sep)
Given(
/^a file named "(.*)" with:$/,
async function (this: World, filePath: string, fileContent: string) {
const absoluteFilePath = path.join(this.tmpDir, filePath)
if (filePath === '@rerun.txt') {
fileContent = fileContent.replace(/\//g, path.sep)
}
await fsExtra.outputFile(absoluteFilePath, fileContent)
}
await fsExtra.outputFile(absoluteFilePath, fileContent)
})
)

Given(/^an empty file named "(.*)"$/, async function (
this: World,
filePath: string
) {
const absoluteFilePath = path.join(this.tmpDir, filePath)
await fsExtra.outputFile(absoluteFilePath, '')
})
Given(
/^an empty file named "(.*)"$/,
async function (this: World, filePath: string) {
const absoluteFilePath = path.join(this.tmpDir, filePath)
await fsExtra.outputFile(absoluteFilePath, '')
}
)

Given(/^a directory named "(.*)"$/, async function (
this: World,
filePath: string
) {
const absoluteFilePath = path.join(this.tmpDir, filePath)
await fsExtra.mkdirp(absoluteFilePath)
})
Given(
/^a directory named "(.*)"$/,
async function (this: World, filePath: string) {
const absoluteFilePath = path.join(this.tmpDir, filePath)
await fsExtra.mkdirp(absoluteFilePath)
}
)

Given(/^"([^"]*)" is an absolute path$/, function (
this: World,
filePath: string
) {
filePath = Mustache.render(filePath, this)
expect(path.isAbsolute(filePath)).to.eql(true)
})
Given(
/^"([^"]*)" is an absolute path$/,
function (this: World, filePath: string) {
filePath = Mustache.render(filePath, this)
expect(path.isAbsolute(filePath)).to.eql(true)
}
)

Then(/^the file "([^"]*)" has the text:$/, async function (
this: World,
filePath: string,
text: string
) {
filePath = Mustache.render(filePath, this)
const absoluteFilePath = path.resolve(this.tmpDir, filePath)
const content = await fs.readFile(absoluteFilePath, 'utf8')
const actualContent = normalizeText(content)
const expectedContent = normalizeText(text)
expect(actualContent).to.eql(expectedContent)
})
Then(
/^the file "([^"]*)" has the text:$/,
async function (this: World, filePath: string, text: string) {
filePath = Mustache.render(filePath, this)
const absoluteFilePath = path.resolve(this.tmpDir, filePath)
const content = await fs.readFile(absoluteFilePath, 'utf8')
const actualContent = normalizeText(content)
const expectedContent = normalizeText(text)
expect(actualContent).to.eql(expectedContent)
}
)

0 comments on commit 7fd71e1

Please sign in to comment.