Skip to content

Cannot read properties of undefined (reading 'line') at test_case_attempt_parser.ts #2226

@pawelrochala

Description

@pawelrochala

👓 What did you see?

Hi I have following stacktrace

TypeError: Cannot read properties of undefined (reading 'line')
    at parseTestCaseAttempt (/home/rochala/workspace/ui/aa/cuc/node_modules/@cucumber/cucumber/src/formatter/helpers/test_case_attempt_parser.ts:147:9)
    at formatTestCaseAttempt (/home/rochala/workspace/ui/aa/cuc/node_modules/@cucumber/cucumber/src/formatter/helpers/test_case_attempt_formatter.ts:99:38)
    at formatIssue (/home/rochala/workspace/ui/aa/cuc/node_modules/@cucumber/cucumber/src/formatter/helpers/issue_helpers.ts:51:57)
    at /home/rochala/workspace/ui/aa/cuc/node_modules/@cucumber/cucumber/src/formatter/summary_formatter.ts:84:20
    at Array.forEach (<anonymous>)
    at ProgressFormatter.logIssues (/home/rochala/workspace/ui/aa/cuc/node_modules/@cucumber/cucumber/src/formatter/summary_formatter.ts:82:12)
    at ProgressFormatter.logSummary (/home/rochala/workspace/ui/aa/cuc/node_modules/@cucumber/cucumber/src/formatter/summary_formatter.ts:66:12)
    at EventEmitter.<anonymous> (/home/rochala/workspace/ui/aa/cuc/node_modules/@cucumber/cucumber/src/formatter/summary_formatter.ts:27:14)
    at EventEmitter.emit (node:events:539:35)
    at EventEmitter.emit (node:domain:475:12)

I checked the logic in parseTestCaseAttempt and it seems that
gherkinScenarioLocationMap keys doesn't match provided picke id.

✅ What did you expect to see?

A correct summary.

📦 Which tool/library version are you using?

"@cucumber/cucumber": "8.10.0",
"@types/yargs": "17.0.20",
"playwright": "1.29.2",
"ts-node": "10.9.1",
"typescript": "4.9.4",
"yargs": "17.6.2"

Node.js v16.16.0.

🔬 How could we reproduce it?

I'm running :
"cucumber-js --config src/cucumber.json src/features/*.feature --require-module ts-node/register --require src/setup.ts"

cucumber.json:

{
  "default": {
    "baseURL": "http://localhost:8080",
    "require": ["src/steps/**/*.ts", "src/setup.ts"],
    "requireModule": ["ts-node/register"],
    "paths": ["src/features/*.feature"]
  }
}

setup.js

import {
  Before,
  BeforeAll,
  ITestCaseHookParameter,
  setDefaultTimeout,
  World as CucumberWorld,
} from '@cucumber/cucumber';
import { BrowserContext, chromium, devices, Page } from 'playwright';
import yargs from 'yargs';

const argv: any = yargs(process.argv).parse();
const config: any = require('./cucumber.json')[argv.p || 'default'];
const globalAny: any = global;
const DEFAULT_TIMEOUT: number = 60000;

setDefaultTimeout(DEFAULT_TIMEOUT);
BeforeAll(async function () {
  globalAny.browser = await chromium.launch({
    headless: config.headless,
    slowMo: config.slowMo,
    timeout: DEFAULT_TIMEOUT,
  });
});


Before(async function (this: SstWorld, parameter: ITestCaseHookParameter) {
  const chrome: any = devices['Desktop Chrome'];
  this.context = await globalAny.browser.newContext({
    viewport: chrome.viewport,
    userAgent: chrome.userAgent,
    baseURL: config.baseURL,
  });
  this.page = await this.context.newPage();
});

export interface SstWorld extends CucumberWorld {
  context: BrowserContext;
  page: Page;
}

screenshot

📚 Any additional context?


This text was originally generated from a template, then edited by hand. You can modify the template here.

Metadata

Metadata

Assignees

Labels

🐛 bugDefect / Bug✅ acceptedThe core team has agreed that it is a good idea to fix this

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions