skip to Main Content

How can I open an existing cypress tests in cypress?
I have a project which already have some cypress tests but when I am installing cypress to get all the project’s tests it is creating another cypress folder and never seeing the old projects tests?

Thank you

Zombie says in comments

import { defineConfig } from "cypress"; 

export default defineConfig({ 
  chromeWebSecurity: false, 
  screenshotOnRunFailure: true, 
  env: { PASSWORD: "xxx", }, 
  e2e: { url: "xxx", }, 
});

2

Answers


  1. It seems to me that you are setting a TypeScript config file, but you are trying to run it as if it was JavaScript (from your comments: npx cypress run –config-file=cypress.config.js). If your app is JavaScript, you need to rewrite your configuration file. If the app is TypeScript, then you need to rename the configuration file as cypress.config.ts

    Please, refer to https://docs.cypress.io/guides/references/configuration

    Login or Signup to reply.
  2. Fixing the current project will probably be an arduous task.

    If I were you I’d create a new blank project with the latest Cypress, and move the tests across to it one by one.

    • make a new folder

    • decide if you want typescript, if so install it first

    • install Cypress

    • with no tests or configuration, open Cypress GUI and allow it to set up the folders and files for config and support

    • add the example spec when it is offered, and run it – now your Cypress framework is active

    • compare the new config with your old one, try not to copy anything that will break the new config, then run the example test again to make sure it still works

    • copy across the simplest spec from old project,

      • test it,
      • repeat for the rest

    Then you can raise specific questions on SO for each test that does not work, and there is no guesswork about what issues you might have in the old project.

    Also, I would add CI only after all tests are working locally.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search