https://cypress.io logo
Issue when I'm trying to iterate on fixture with f...
# i-need-help
q
Hello, I'm using fixtures for the first time and took a snippet of code from cypress github but I can't get it to work. I want to iterate with foreach to read each item but I always have this error message : examples.forEach is not a function code I'm currently using : it('gets its data from a fixture', function() { cy.fixture('examples') .then((examples) => { //
examples
contains the full contents of the fixture examples.forEach((example) => { // Do something with each example }); }); }); content of the fixture file (examples.json) : { "email": "sam_blogs@webdriveruni.com", "otheremail": "sam_blogs@webdriveruni.com" } Do you have any idea what I'm doing wrong please ? Thanks ! Leila

https://cdn.discordapp.com/attachments/1104678206390423583/1104678206633685073/fixture_issue.png

e
forEach is an array method, your fixture is an object not an array
q
Thanks you, all work now, I put an array in the input data