cypress-io/cypress-and-jest-typescript-example

Mocha and Chai clashes on cypress run

mspoulsen opened this issue · 1 comments

Hi,

I am setting up vue + jest + cypress and following along this example repo :)
Things are progressing nicely. My (jest) unit tests are working, "cypress open" is working. But when I run "cypress run" I get: "Cannot redeclare block-scoped variable 'chai' " and lots of other error indicating a conflict between Mocha, Chia and Jest.

My two config tsconfig files are:

Root:

  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "strict": true,
    "jsx": "preserve",
    "importHelpers": true,
    "moduleResolution": "node",
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "resolveJsonModule": true,
    "sourceMap": true,
    "baseUrl": ".",
    "types": [
      "webpack-env",
      "jest",
      "vuetify",
      "node",
      "cypress",
      "mocha",
      "chai"
    ],
    "paths": {
      "@/*": [
        "src/*"
      ]
    },
    "lib": [
      "esnext",
      "dom",
      "dom.iterable",
      "scripthost"
    ]
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.tsx",
    "src/**/*.vue",
    "tests/**/*.ts",
    "tests/**/*.tsx",
    "custom-typings/*.ts"
  ],
  "exclude": [
    "node_modules",
    
  ]
}

/cypress:

  "extends": "../tsconfig.json",
  "include": [
    "../node_modules/cypress",
    "*/*.ts"
  ]
}

I have tried excluding cypress from the root tsconfig but then the cypress open fails.

Why would I get errors on cypress run but not on cypress open?

Can you help me?

Thanks in advance!