Skip to content

Commit

Permalink
typescript: noImplicitThis (#1283)
Browse files Browse the repository at this point in the history
  • Loading branch information
charlierudolph committed Mar 7, 2020
1 parent a0bac7f commit 6b2b1df
Show file tree
Hide file tree
Showing 23 changed files with 1,214 additions and 910 deletions.
8 changes: 6 additions & 2 deletions features/step_definitions/fixture_steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ import {
} from '../support/formatter_output_helpers'
import fs from 'mz/fs'
import path from 'path'
import { World } from '../support/world'
import { messages } from 'cucumber-messages'

Then(
'the {string} formatter output matches the fixture {string}',
async function(formatter: string, filePath: string) {
async function(this: World, formatter: string, filePath: string) {
let actual: any
if (formatter === 'message') {
actual = this.lastRun.envelopes.map(e => e.toJSON())
actual = this.lastRun.envelopes.map(e =>
(e as messages.Envelope).toJSON()
)
actual = normalizeMessageOutput(actual, this.tmpDir)
} else {
const actualPath = path.join(this.tmpDir, `${formatter}.out`)
Expand Down
35 changes: 28 additions & 7 deletions features/step_definitions/message_steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,52 @@ import {
getTestStepResults,
} from '../support/message_helpers'
import { messages } from 'cucumber-messages'
import { World } from '../support/world'

const { Status } = messages.TestResult

Then('it runs {int} scenarios', function(expectedCount) {
Then('it runs {int} scenarios', function(this: World, expectedCount) {
const testCaseStartedEvents = _.filter(
this.lastRun.envelopes,
e => e.testCaseStarted
)
expect(testCaseStartedEvents).to.have.lengthOf(expectedCount)
})

Then('it runs the scenario {string}', function(name) {
Then('it runs the scenario {string}', function(this: World, name) {
const actualNames = getPickleNamesInOrderOfExecution(this.lastRun.envelopes)
expect(actualNames).to.eql([name])
})

Then('it runs the scenarios {string} and {string}', function(name1, name2) {
Then('it runs the scenarios {string} and {string}', function(
this: World,
name1,
name2
) {
const actualNames = getPickleNamesInOrderOfExecution(this.lastRun.envelopes)
expect(actualNames).to.eql([name1, name2])
})

Then('it runs the scenarios:', function(table) {
Then('it runs the scenarios:', function(this: World, table) {
const expectedNames = table.rows().map(row => row[0])
const actualNames = getPickleNamesInOrderOfExecution(this.lastRun.envelopes)
expect(expectedNames).to.eql(actualNames)
})

Then('scenario {string} has status {string}', function(name, status) {
Then('scenario {string} has status {string}', function(
this: World,
name,
status
) {
const result = getTestCaseResult(this.lastRun.envelopes, name)
expect(result.status).to.eql(Status[status.toUpperCase()])
})

Then('the scenario {string} has the steps:', function(name, table) {
Then('the scenario {string} has the steps:', function(
this: World,
name,
table
) {
const actualTexts = getTestStepResults(this.lastRun.envelopes, name).map(
s => s.text
)
Expand All @@ -52,6 +65,7 @@ Then('the scenario {string} has the steps:', function(name, table) {
})

Then('scenario {string} step {string} has status {string}', function(
this: World,
pickleName,
stepText,
status
Expand All @@ -63,7 +77,7 @@ Then('scenario {string} step {string} has status {string}', function(

Then(
'scenario {string} attempt {int} step {string} has status {string}',
function(pickleName, attempt, stepText, status) {
function(this: World, pickleName, attempt, stepText, status) {
const testStepResults = getTestStepResults(
this.lastRun.envelopes,
pickleName,
Expand All @@ -75,6 +89,7 @@ Then(
)

Then('scenario {string} {string} hook has status {string}', function(
this: World,
pickleName,
hookKeyword,
status
Expand All @@ -85,6 +100,7 @@ Then('scenario {string} {string} hook has status {string}', function(
})

Then('scenario {string} step {string} failed with:', function(
this: World,
pickleName,
stepText,
errorMessage
Expand All @@ -96,6 +112,7 @@ Then('scenario {string} step {string} failed with:', function(
})

Then('scenario {string} attempt {int} step {string} failed with:', function(
this: World,
pickleName,
attempt,
stepText,
Expand All @@ -112,6 +129,7 @@ Then('scenario {string} attempt {int} step {string} failed with:', function(
})

Then('scenario {string} step {string} has the doc string:', function(
this: World,
pickleName,
stepText,
docString
Expand All @@ -121,6 +139,7 @@ Then('scenario {string} step {string} has the doc string:', function(
})

Then('scenario {string} step {string} has the data table:', function(
this: World,
pickleName,
stepText,
dataTable
Expand All @@ -130,6 +149,7 @@ Then('scenario {string} step {string} has the data table:', function(
})

Then('scenario {string} step {string} has the attachments:', function(
this: World,
pickleName,
stepText,
table
Expand All @@ -155,6 +175,7 @@ Then('scenario {string} step {string} has the attachments:', function(
})

Then('scenario {string} {string} hook has the attachments:', function(
this: World,
pickleName,
hookKeyword,
table
Expand Down
3 changes: 2 additions & 1 deletion features/step_definitions/usage_json_steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import _ from 'lodash'
import { Then } from '../../'
import { expect } from 'chai'
import path from 'path'
import { World } from '../support/world'

Then('it outputs the usage data:', function(table) {
Then('it outputs the usage data:', function(this: World, table) {
const usageData = JSON.parse(this.lastRun.output)
table.hashes().forEach(row => {
const rowUsage = _.find(
Expand Down

0 comments on commit 6b2b1df

Please sign in to comment.