Skip to main content

TypeScript support

Overview

Eyes Cypress supports TypeScript.

Configure tsconfig.json

To work with TypeScript, in the tsconfig.json file, located in the cypress folder, add the following:

tsconfig.json
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "@applitools/eyes-cypress", "node"],
"moduleResolution": "node" // or "moduleResolution": "node16"
},
"include": ["**/*.ts"]
}

"Types" and "moduleResolution" are required to for the tsc compiler.

  • "types"

    • "cypress" - Required by Cypress
    • "@applitools/eyes-cypress" - Type definition to define protocols in Applitools Eyes.
    • "node" - Required by Applitools Eyes
  • "moduleResolution"

Applitools Eyes currently supports "node" and "node16".

Configure cypress.config.ts

Modify the cypress.config.ts file to establish a protocol between Applitools Eyes and Cypress as follows:

cypress.config.ts
import {defineConfig} from 'cypress'
import eyesPlugin from '@applitools/eyes-cypress'

export default eyesPlugin(defineConfig({
....
}))
differences
import {defineConfig} from 'cypress'
+import eyesPlugin from '@applitools/eyes-cypress'

-export default defineConfig({
+export default eyesPlugin(defineConfig({
....
-})
+}))