Florestan Korp
Florestan Korp

Reputation: 712

Not 'sourceType: module' error when testing Angular with Cypress in TypeScript

I'm inside of an Angular 8 project with Cypress version 4.2.0 and getting the following error when trying to import .ts files

/.../cypress/integration/main.spec.ts:1
import { MOCK1, MOCK2, MOCK3 } from '../fixtures/mocks/index';
^
ParseError: 'import' and 'export' may appear only with 'sourceType: module'

My tsconfig.json:

{
    "compilerOptions": {
        "strict": true,
        "baseUrl": "../node_modules",
        "target": "ES6",
        "lib": ["es5", "dom"],
        "types": ["cypress"]
    },
    "include": ["**/*.ts"]
}

Upvotes: 1

Views: 357

Answers (1)

Evgenii Bazhanov
Evgenii Bazhanov

Reputation: 926

Looks like it is required sourceType": "module"

{
  "parser": "babel-eslint",
  "parserOptions": {
    "sourceType": "module",
    "allowImportExportEverywhere": true
  }
}

Reference link https://github.com/babel/babel-eslint#configuration

Upvotes: 1

Related Questions