diff --git a/CHANGELOG.md b/CHANGELOG.md index 46a27349d..40d719c3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,9 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO ### Fixed +* All messages now emitted with project-relative `uri`s + ([#1534](https://github.com/cucumber/cucumber-js/issues/1534) + [#1672](https://github.com/cucumber/cucumber-js/pull/1672)) * Json formatter now works with tagged examples ([#1621](https://github.com/cucumber/cucumber-js/issues/1621) [#1651](https://github.com/cucumber/cucumber-js/pull/1651)) diff --git a/src/cli/helpers.ts b/src/cli/helpers.ts index bbed9af13..a66d88f02 100644 --- a/src/cli/helpers.ts +++ b/src/cli/helpers.ts @@ -2,7 +2,6 @@ import _ from 'lodash' import ArgvParser from './argv_parser' import ProfileLoader from './profile_loader' import shuffle from 'knuth-shuffle-seeded' -import path from 'path' import { EventEmitter } from 'events' import PickleFilter from '../pickle_filter' import { EventDataCollector } from '../formatter/helpers' @@ -69,10 +68,7 @@ export async function parseGherkinMessageStream({ if (doesHaveValue(envelope.parseError)) { reject( new Error( - `Parse error in '${path.relative( - cwd, - envelope.parseError.source.uri - )}': ${envelope.parseError.message}` + `Parse error in '${envelope.parseError.source.uri}': ${envelope.parseError.message}` ) ) } diff --git a/src/cli/index.ts b/src/cli/index.ts index 9db169ad4..3c2d5fe96 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -205,6 +205,7 @@ export default class Cli { { defaultDialect: configuration.featureDefaultLanguage, newId, + relativeTo: this.cwd, } ) const pickleIds = await parseGherkinMessageStream({ diff --git a/src/formatter/helpers/issue_helpers_spec.ts b/src/formatter/helpers/issue_helpers_spec.ts index ddae29f74..1a63a3f71 100644 --- a/src/formatter/helpers/issue_helpers_spec.ts +++ b/src/formatter/helpers/issue_helpers_spec.ts @@ -11,7 +11,7 @@ async function testFormatIssue(sourceData: string): Promise { const sources = [ { data: sourceData, - uri: 'project/a.feature', + uri: 'a.feature', }, ] const supportCodeLibrary = getBaseSupportCodeLibrary() diff --git a/src/formatter/helpers/test_case_attempt_parser.ts b/src/formatter/helpers/test_case_attempt_parser.ts index 4181a7034..82920d490 100644 --- a/src/formatter/helpers/test_case_attempt_parser.ts +++ b/src/formatter/helpers/test_case_attempt_parser.ts @@ -5,7 +5,6 @@ import { getGherkinStepMap, } from './gherkin_document_parser' import { getPickleStepMap, getStepKeyword } from './pickle_parser' -import path from 'path' import * as messages from '@cucumber/messages' import { ITestCaseAttempt } from './event_data_collector' import StepDefinitionSnippetBuilder from '../step_definition_snippet_builder' @@ -138,7 +137,7 @@ export function parseTestCaseAttempt({ gherkinDocument ) const pickleStepMap = getPickleStepMap(pickle) - const relativePickleUri = path.relative(cwd, pickle.uri) + const relativePickleUri = pickle.uri const parsedTestCase: IParsedTestCase = { attempt: testCaseAttempt.attempt, name: pickle.name, diff --git a/src/formatter/helpers/usage_helpers/index.ts b/src/formatter/helpers/usage_helpers/index.ts index a5fa528e6..6c53ed54a 100644 --- a/src/formatter/helpers/usage_helpers/index.ts +++ b/src/formatter/helpers/usage_helpers/index.ts @@ -1,6 +1,5 @@ import _ from 'lodash' import { getPickleStepMap } from '../pickle_parser' -import path from 'path' import { getGherkinStepMap } from '../gherkin_document_parser' import * as messages from '@cucumber/messages' import StepDefinition from '../../../models/step_definition' @@ -73,7 +72,7 @@ function buildMapping({ const match: IUsageMatch = { line: gherkinStep.location.line, text: pickleStep.text, - uri: path.relative(cwd, testCaseAttempt.pickle.uri), + uri: testCaseAttempt.pickle.uri, } const { duration, status } = testCaseAttempt.stepResults[testStep.id] if (!unexecutedStatuses.includes(status) && doesHaveValue(duration)) { diff --git a/src/formatter/json_formatter.ts b/src/formatter/json_formatter.ts index 628cdcf78..a0d31837b 100644 --- a/src/formatter/json_formatter.ts +++ b/src/formatter/json_formatter.ts @@ -1,7 +1,6 @@ import _ from 'lodash' import Formatter, { IFormatterOptions } from './' import { formatLocation, GherkinDocumentParser, PickleParser } from './helpers' -import path from 'path' import * as messages from '@cucumber/messages' import { getGherkinExampleRuleMap, @@ -136,7 +135,7 @@ export default class JsonFormatter extends Formatter { this.eventDataCollector.getTestCaseAttempts(), (testCaseAttempt: ITestCaseAttempt) => { if (!testCaseAttempt.worstTestStepResult.willBeRetried) { - const uri = path.relative(this.cwd, testCaseAttempt.pickle.uri) + const uri = testCaseAttempt.pickle.uri if (doesNotHaveValue(groupedTestCaseAttempts[uri])) { groupedTestCaseAttempts[uri] = [] } diff --git a/src/formatter/rerun_formatter.ts b/src/formatter/rerun_formatter.ts index 49c65b8ed..6b5c53310 100644 --- a/src/formatter/rerun_formatter.ts +++ b/src/formatter/rerun_formatter.ts @@ -1,6 +1,5 @@ import _ from 'lodash' import Formatter, { IFormatterOptions } from './' -import path from 'path' import { getGherkinScenarioLocationMap } from './helpers/gherkin_document_parser' import { doesHaveValue, @@ -37,7 +36,7 @@ export default class RerunFormatter extends Formatter { if ( worstTestStepResult.status !== messages.TestStepResultStatus.PASSED ) { - const relativeUri = path.relative(this.cwd, pickle.uri) + const relativeUri = pickle.uri const line = getGherkinScenarioLocationMap(gherkinDocument)[ _.last(pickle.astNodeIds) ].line diff --git a/src/pickle_filter.ts b/src/pickle_filter.ts index fcf774ebe..a03745d22 100644 --- a/src/pickle_filter.ts +++ b/src/pickle_filter.ts @@ -1,5 +1,4 @@ import _ from 'lodash' -import path from 'path' import parse from '@cucumber/tag-expressions' import { getGherkinScenarioLocationMap } from './formatter/helpers/gherkin_document_parser' import { doesHaveValue, doesNotHaveValue } from './value_checker' @@ -73,7 +72,7 @@ export class PickleLineFilter { featurePaths.forEach((featurePath) => { const match = FEATURE_LINENUM_REGEXP.exec(featurePath) if (doesHaveValue(match)) { - const uri = path.resolve(cwd, match[1]) + const uri = match[1] const linesExpression = match[2] if (doesHaveValue(linesExpression)) { if (doesNotHaveValue(mapping[uri])) { diff --git a/src/pickle_filter_spec.ts b/src/pickle_filter_spec.ts index 392283514..0c5b70523 100644 --- a/src/pickle_filter_spec.ts +++ b/src/pickle_filter_spec.ts @@ -91,7 +91,7 @@ describe('PickleFilter', () => { gherkinDocument, } = await parse({ data: ['Feature: a', '', 'Scenario: b', 'Given a step'].join('\n'), - uri: path.resolve(cwd, 'features/b.feature'), + uri: 'features/b.feature', }) // Act