cypress: Studio: failed to save commands

Current behavior

2021-01-27 08 50 54

Test code to reproduce

I created a new repo, added cypress, did cypress open, deleted examples, created a new spec:

describe('soak test', () => {

	it('logs in', () => {

		cy.visit('internal url');

	});

});

Then I opened studio, typed into an input and clicked save.

The page refreshes so I needed to use animation capture to see the error.

How can I provide more details on the exact error? I don’t see anything in the debug log but I will attach it here.

Versions

6.3.0 windows 10

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 23 (16 by maintainers)

Most upvoted comments

My test case file was exactly as I put in the initial description and it was a brand new setup - all I did was enable studio.

We’ve just released copy to clipboard in v7.7.0 - check it out and let us know what you think!

We’re still working on a more dedicated fix to prevent this message from occurring in the first place but copy to clipboard should help out in the meantime.

@panzarino It did add a new test in the example above, just not exactly in the expected place. I just mean, it didn’t completely fail. The copy to clipboard is a solution anyone could use though.

I was also seeing this error, but we use a custom suite function that does some setup before work (reset db, authenticate as a specific user type). When I removed the custom suite method and used a standard describe it was able to write the commands.

Given that there may be non-standard setups like this, it would be a useful feature to simply display the commands in a modal so the user could copy/paste them rather than trying to parse the file and write to disk.

Setup: Cypress 6.4.0 (Mac) Electron 87.0.4280.141

Before (using our custom suite function):

suite('ADMIN', 'Suite Name', () => {
  it('does', () => {
    cy.visit('/#/home')
  });
});

After (standard describe):

describe('suite', () => {
  it('logs in', () => {
    cy.visit('/#/login')
    /* ==== Generated with Cypress Studio ==== */
    cy.get('.emailInput').type('asdasd');
    cy.get('.passwordInput').type('asdasd');
    /* ==== End Cypress Studio ==== */
  });
});

Custom suite function (basically extends describe):

const suite = (
  user: UserType,
  suiteName: string,
  fn: RunnerFn,
): Suite => {
  return describe(`Suite: ${suiteName}`, function suiteDescribe() {
    before(() => {
      resetDatabase();
      logInAs(user);
    });
    beforeEach(() => {
      cy.restoreLocalStorage();
    });
    fn.apply(this);
  });
};

Relevant Packages:

"@cypress/webpack-preprocessor": "^5.5.0",
"cypress": "6.4.0",
"cypress-file-upload": "^4.1.1",
"cypress-localstorage-commands": "^1.1.6",
"cypress-plugin-snapshots": "^1.4.4",
"ts-loader": "^5",
"typescript": "3.7.3",

Webpack preprocessor options:

extensions: ['.ts', '.tsx', '.js'],
test: /\.tsx?$/,
loader: 'ts-loader',
options: { transpileOnly: true },