Update TypeScript preprocessor examples (items.map is not a function)
See original GitHub issueCurrent behavior
If I follow the webpack-preprocessor or browsify-preprocessor examples for TypeScript projects (see https://github.com/badeball/cypress-cucumber-preprocessor/tree/e450dc107374071c26318f14f351f56d559e7670/examples/browserify-ts) for cypress.config.ts in a TypeScript/Angular project, all of my tests throw the following error on line 576 of node_modules/@badeball/cypress-cucumber-preprocessor/lib/create-tests.js :
TypeError items.map is not a function node_modules/@badeball/cypress-cucumber-preprocessor/lib/create-tests.js:576:1
574 | : noStepDefinitionPathsTemplate;
575 | const maybeEscape = (string) => strictIsInteractive() ? string.replace("*", "\\*") : string;
> 576 | const prettyPrintList = (items) => items.map((item) => " - " + maybeEscape(item)).join("\n");
| ^
577 | return stripIndent(template)
578 | .replaceAll("<text>", text)
579 | .replaceAll("<step-definitions>", prettyPrintList(stepDefinitionHints.stepDefinitions))
Desired behavior
The documentation and examples should work without these errors in TypeScript projects.
Test code to reproduce
Versions
- Cypress version: 10.3.0
- Preprocessor version: 11.5.1
- Node version: 16.14.0
Checklist
- [ x] I’ve read the FAQ.
- [x ] I’ve read Instructions for logging issues.
- [ x] I’m not using
cypress-cucumber-preprocessor@4.3.1
(package name has changed and it is no longer the most recent version, see #689).
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
TypeError: items.map is not a function , how to solve this error
All Json data are not array. Just check the data that you are trying to pass to the map function.
Read more >webpack-preprocessor cleanError throws TypeError #8948
TypeError: err.replace is not a function. It seems err is an Error in my case, not a string . I'm not familiar enough...
Read more >Changelog - Cypress Documentation
Fixed an issue with Angular Component Testing where a custom sourceRoot configuration would not be respected. Fixes #24827. Fixed Typescript typings for cy....
Read more >Working with JavaScript in Visual Studio Code
Working with JavaScript. This topic describes some of the advanced JavaScript features supported by Visual Studio Code. Using the TypeScript language ...
Read more >JSX In Depth - React
For example, this code will not run as expected: import React from 'react'; // Wrong! This is a component and should have been...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
A fix for the above-mentioned issue has been released in v12.0.0.
You’ve indeed stumbled upon a bug, in part of the code that was going to show you a more thorough and informative error message. It has nothing to do with Angular though. For now you can circumvent it by configuring step definitions as array of string(s) instead of a string.