-
-
Notifications
You must be signed in to change notification settings - Fork 149
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
Update TypeScript preprocessor examples (items.map is not a function) #781
Comments
Can't reproduce, the examples work fine. Why would you completely omit any information to reproduce the error? |
I couldn't think of a way to share an entire Angular framework and allow you to run Cypress e2e tests in it (be it StackBlitz, jsFiddle, etc). I can run angular projects in those but can't run Cypress in those. I assure you, the current instruction set/code base does not work on Angular (a very popular Google front end framework). I was able to finagle TheBrainFamily's cypress-cucumber-preprocessor version 4.3.1 to work (except that running tests via tags did not work - all tests ran regardless of what tag I used). But any cypress-cucumber-preprocessor version past 4.3.1 (aka @badeball ) does not work with Angular. The only way for you to reproduce would be, on your local machine, set up an angular project like so:
This will prompt you to install an e2e test framework. Select 'Cypress' - this will install the cypress-schematic version 2. Cypress-schematic is just Angular's way of installing Cypress. NOTE: if you are not prompted to install an e2e framework, just run Okay, now Cypress v10 is set up. Now we run Then we add our configurations in package.json like so:
Then we install a preprocessor. Let's use Browserify: Then we modify cypress.config.ts in the project root, using the typescript example provided in this repo. Then we write a simple Cucumber/Gherkin test. Then we run ng e2e, and all the tests will fail with typeerror: items.map is not a function |
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. |
A fix for the above-mentioned issue has been released in v12.0.0. |
Thanks for the hard work @badeball . After changing stepDefinitions to an array of strings, I get better error messages, and I can now see that my issue was my filepath in the specDefinitions property of package.json. I still had the value I was using in cypress-cucumber-preprocessor v4.3.1. In @badeball/cypress-cucumber-preprocessor v11.0.0 and up, I needed to change this to a more specific value (even though my directory structure was the same) and include the file extension as well. I changed stepDefinitions in package.json to the following, and now all works well in Angular! (including tags).
Much appreciated |
Current 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
Desired behavior
The documentation and examples should work without these errors in TypeScript projects.
Test code to reproduce
Versions
Checklist
cypress-cucumber-preprocessor@4.3.1
(package name has changed and it is no longer the most recent version, see #689).The text was updated successfully, but these errors were encountered: