jeudi 1 octobre 2020

Cypress fixtures implementation in typescript

I am trying to use fixtures to pull input data and type in it into a text area. But while loading the data I am receiving the following error. I am not sure what I am missing.

Error

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'global'
    --- property 'parent' closes the circle
    at JSON.stringify (<anonymous>)

Fixture: dataSource.json

{
    "input": "Hello"
}

Test case test.ts

describe('test', () => {
    const fixtureDocSource = 'testCases/dataSource.json';
    before(() => {
        cy.fixture(fixtureDocSource).as('inputData');
    });

    it('login test', () => {
        const inputText = JSON.stringify(
            cy.get('@inputData').then((fixtureData: any) => {
                return fixtureData.input;
            })
        );

        cy.get("textBox").type(prId).type('{enter}');
    });
)};

Any help appreciated.

Aucun commentaire:

Enregistrer un commentaire