Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: add noImplicitAny and noImplicitReturns, fix compilation #1286

Merged
merged 33 commits into from Mar 7, 2020
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b88ae4d
add noImplicitReturns to tsconfig.json
davidjgoss Feb 3, 2020
fda9549
add noImplicitAny to tsconfig.json
davidjgoss Feb 3, 2020
8812c5e
some progress
davidjgoss Feb 3, 2020
13c7828
more progress
davidjgoss Feb 3, 2020
428296b
add typings for verror package
davidjgoss Feb 3, 2020
825064d
more progress
davidjgoss Feb 3, 2020
da5c23c
more progress
davidjgoss Feb 3, 2020
45ba630
whoops
davidjgoss Feb 3, 2020
8d7d71c
more progress
davidjgoss Feb 3, 2020
e332b75
this interface was a bit unnecessary
davidjgoss Feb 3, 2020
0495e31
use I convention consistently on types
davidjgoss Feb 3, 2020
a9fe91f
install types for progress library
davidjgoss Feb 3, 2020
bf61138
more progress
davidjgoss Feb 3, 2020
44d0d4f
more progress
davidjgoss Feb 3, 2020
3d20539
nearly there
davidjgoss Feb 3, 2020
0e99986
add typings for resolve
davidjgoss Feb 3, 2020
c017ecc
almost
davidjgoss Feb 3, 2020
861a873
fix more test code
davidjgoss Feb 4, 2020
59a2975
fix type from any to string
davidjgoss Feb 6, 2020
3a537b5
fix up compilation for feature test support code
davidjgoss Feb 6, 2020
16903e1
declare types in way that works for both typescript and ts-node
davidjgoss Feb 7, 2020
61be36b
fix all of the unit tests!
davidjgoss Feb 7, 2020
085fb83
use `ensureSymlinkSync` as it's in the documented API
davidjgoss Feb 8, 2020
c4a87bd
use EventEmitter instead of custom interface
davidjgoss Mar 5, 2020
0f47556
fix up cucumber-messages imports
davidjgoss Mar 6, 2020
08dce29
remove empty lines
davidjgoss Mar 6, 2020
f7e3975
remove unnecessary Partial
davidjgoss Mar 7, 2020
5798f7a
move type to appropriate file
davidjgoss Mar 7, 2020
7add934
create interfaces for helper function request objects
davidjgoss Mar 7, 2020
7f5ef3a
avoid awkward casting by adding PassThrough to formatter stream inter…
davidjgoss Mar 7, 2020
1946980
drop redundant key from objct literal
davidjgoss Mar 7, 2020
ad6c22d
merge from master
davidjgoss Mar 7, 2020
5a6c4b8
fix last few issues after merging master
davidjgoss Mar 7, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 13 additions & 7 deletions features/step_definitions/cli_steps.ts
@@ -1,4 +1,4 @@
import { When, Then } from '../../'
import { When, Then, DataTable } from '../../'
import { expect } from 'chai'
import { normalizeText } from '../support/helpers'
import stringArgv from 'string-argv'
Expand Down Expand Up @@ -39,7 +39,7 @@ When(
When(
/^I run cucumber-js \(installed (locally|globally)\)$/,
{ timeout: 10000 },
async function(this: World, location) {
async function(this: World, location: string) {
if (location === 'locally') {
return this.run(this.localExecutablePath, [])
}
Expand All @@ -57,27 +57,30 @@ Then(/^it fails$/, function(this: World) {
this.verifiedLastRunError = true
})

Then(/^it outputs the text:$/, function(this: World, text) {
Then(/^it outputs the text:$/, function(this: World, text: string) {
const actualOutput = normalizeText(this.lastRun.output)
const expectedOutput = normalizeText(text)
expect(actualOutput).to.eql(expectedOutput)
})

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

Then('the output does not contain the text:', function(this: World, text) {
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
table: DataTable
) {
const actualOutput = normalizeText(this.lastRun.errorOutput)
table.rows().forEach(row => {
Expand All @@ -86,7 +89,10 @@ Then(/^the error output contains the text snippets:$/, function(
})
})

Then(/^the error output contains the text:$/, function(this: World, text) {
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)
Expand Down
31 changes: 20 additions & 11 deletions features/step_definitions/file_steps.ts
Expand Up @@ -7,37 +7,46 @@ import path from 'path'
import Mustache from 'mustache'
import { World } from '../support/world'

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

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

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

Given(/^"([^"]*)" is an absolute path$/, function(this: World, filePath) {
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,
text
filePath: string,
text: string
) {
filePath = Mustache.render(filePath, this)
const absoluteFilePath = path.resolve(this.tmpDir, filePath)
Expand Down
4 changes: 3 additions & 1 deletion features/step_definitions/fixture_steps.ts
Expand Up @@ -6,13 +6,15 @@ import {
} from '../support/formatter_output_helpers'
import fs from 'mz/fs'
import path from 'path'
import { messages } from 'cucumber-messages'
import Envelope = messages.Envelope
davidjgoss marked this conversation as resolved.
Show resolved Hide resolved

Then(
'the {string} formatter output matches the fixture {string}',
async function(formatter: string, filePath: string) {
let actual: any
if (formatter === 'message') {
actual = this.lastRun.envelopes.map(e => e.toJSON())
actual = this.lastRun.envelopes.map((e: Envelope) => e.toJSON())
actual = normalizeMessageOutput(actual, this.tmpDir)
} else {
const actualPath = path.join(this.tmpDir, `${formatter}.out`)
Expand Down
107 changes: 69 additions & 38 deletions features/step_definitions/message_steps.ts
Expand Up @@ -3,47 +3,67 @@ import { Then } from '../../'
import { expect } from 'chai'
import DataTable from '../../src/models/data_table'
import {
getPickleStep,
getPickleNamesInOrderOfExecution,
getPickleStep,
getTestCaseResult,
getTestStepAttachmentsForStep,
getTestStepAttachmentsForHook,
getTestStepAttachmentsForStep,
getTestStepResults,
} from '../support/message_helpers'
import { messages } from 'cucumber-messages'

type StringifiedStatus =
| 'UNKNOWN'
| 'PASSED'
| 'SKIPPED'
| 'PENDING'
| 'UNDEFINED'
| 'AMBIGUOUS'
| 'FAILED'

const { Status } = messages.TestResult

Then('it runs {int} scenarios', function(expectedCount) {
Then('it runs {int} scenarios', function(expectedCount: number) {
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(name: string) {
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(
name1: string,
name2: string
) {
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(table: DataTable) {
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(
name: string,
status: string
) {
const result = getTestCaseResult(this.lastRun.envelopes, name)
expect(result.status).to.eql(Status[status.toUpperCase()])
expect(result.status).to.eql(
Status[status.toUpperCase() as StringifiedStatus]
)
})

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

Then('scenario {string} step {string} has status {string}', function(
pickleName,
stepText,
status
pickleName: string,
stepText: string,
status: string
) {
const testStepResults = getTestStepResults(this.lastRun.envelopes, pickleName)
const testStepResult = _.find(testStepResults, ['text', stepText])
expect(testStepResult.result.status).to.eql(Status[status.toUpperCase()])
expect(testStepResult.result.status).to.eql(
Status[status.toUpperCase() as StringifiedStatus]
)
})

Then(
'scenario {string} attempt {int} step {string} has status {string}',
function(pickleName, attempt, stepText, status) {
function(
pickleName: string,
attempt: number,
stepText: string,
status: string
) {
const testStepResults = getTestStepResults(
this.lastRun.envelopes,
pickleName,
attempt
)
const testStepResult = _.find(testStepResults, ['text', stepText])
expect(testStepResult.result.status).to.eql(Status[status.toUpperCase()])
expect(testStepResult.result.status).to.eql(
Status[status.toUpperCase() as StringifiedStatus]
)
}
)

Then('scenario {string} {string} hook has status {string}', function(
pickleName,
hookKeyword,
status
pickleName: string,
hookKeyword: string,
status: string
) {
const testStepResults = getTestStepResults(this.lastRun.envelopes, pickleName)
const testStepResult = _.find(testStepResults, ['text', hookKeyword])
expect(testStepResult.result.status).to.eql(Status[status.toUpperCase()])
expect(testStepResult.result.status).to.eql(
Status[status.toUpperCase() as StringifiedStatus]
)
})

Then('scenario {string} step {string} failed with:', function(
pickleName,
stepText,
errorMessage
pickleName: string,
stepText: string,
errorMessage: string
) {
const testStepResults = getTestStepResults(this.lastRun.envelopes, pickleName)
const testStepResult = _.find(testStepResults, ['text', stepText])
Expand All @@ -96,10 +127,10 @@ Then('scenario {string} step {string} failed with:', function(
})

Then('scenario {string} attempt {int} step {string} failed with:', function(
pickleName,
attempt,
stepText,
errorMessage
pickleName: string,
attempt: number,
stepText: string,
errorMessage: string
) {
const testStepResults = getTestStepResults(
this.lastRun.envelopes,
Expand All @@ -112,27 +143,27 @@ Then('scenario {string} attempt {int} step {string} failed with:', function(
})

Then('scenario {string} step {string} has the doc string:', function(
pickleName,
stepText,
docString
pickleName: string,
stepText: string,
docString: string
) {
const pickleStep = getPickleStep(this.lastRun.envelopes, pickleName, stepText)
expect(pickleStep.argument.docString.content).to.eql(docString)
})

Then('scenario {string} step {string} has the data table:', function(
pickleName,
stepText,
dataTable
pickleName: string,
stepText: string,
dataTable: DataTable
) {
const pickleStep = getPickleStep(this.lastRun.envelopes, pickleName, stepText)
expect(new DataTable(pickleStep.argument.dataTable)).to.eql(dataTable)
})

Then('scenario {string} step {string} has the attachments:', function(
pickleName,
stepText,
table
pickleName: string,
stepText: string,
table: DataTable
) {
const expectedAttachments = table.hashes().map(x => {
return {
Expand All @@ -155,9 +186,9 @@ Then('scenario {string} step {string} has the attachments:', function(
})

Then('scenario {string} {string} hook has the attachments:', function(
pickleName,
hookKeyword,
table
pickleName: string,
hookKeyword: string,
table: DataTable
) {
const expectedAttachments = table.hashes().map(x => {
return {
Expand Down
6 changes: 3 additions & 3 deletions features/step_definitions/usage_json_steps.ts
@@ -1,11 +1,11 @@
import _ from 'lodash'
import { Then } from '../../'
import { Then, DataTable } from '../../'
import { expect } from 'chai'
import path from 'path'

Then('it outputs the usage data:', function(table) {
Then('it outputs the usage data:', function(table: DataTable) {
const usageData = JSON.parse(this.lastRun.output)
table.hashes().forEach(row => {
table.hashes().forEach((row: any) => {
const rowUsage = _.find(
usageData,
datum =>
Expand Down
4 changes: 2 additions & 2 deletions features/support/hooks.ts
Expand Up @@ -37,7 +37,7 @@ Before(function(

const tmpDirNodeModulesPath = path.join(this.tmpDir, 'node_modules')
const tmpDirCucumberPath = path.join(tmpDirNodeModulesPath, 'cucumber')
fsExtra.createSymlinkSync(projectPath, tmpDirCucumberPath)
fsExtra.ensureSymlinkSync(projectPath, tmpDirCucumberPath)
this.localExecutablePath = path.join(projectPath, 'bin', 'cucumber-js')
})

Expand All @@ -55,7 +55,7 @@ Before('@global-install', function(this: World) {
'node_modules',
moduleName
)
fsExtra.createSymlinkSync(
fsExtra.ensureSymlinkSync(
projectNodeModulePath,
globalInstallNodeModulePath
)
Expand Down
5 changes: 4 additions & 1 deletion features/support/message_helpers.ts
Expand Up @@ -42,7 +42,10 @@ export function getPickleStep(
return getPickleStepByStepText(pickle, gherkinDocument, stepText)
}

export function getTestCaseResult(envelopes, pickleName): messages.ITestResult {
export function getTestCaseResult(
envelopes: messages.IEnvelope[],
pickleName: string
): messages.ITestResult {
const pickle = getAcceptedPickle(envelopes, pickleName)
const testCase = getTestCase(envelopes, pickle.id)
const testCaseStartedId = getTestCaseStarted(envelopes, testCase.id).id
Expand Down