| load("@yarn//@bazel/cypress:index.bzl", "cypress_web_test") |
| load("@yarn//@bazel/typescript:index.bzl", "ts_project") |
| |
| # You must create a cypress plugin in order to boot a server to serve your application. |
| # It can be written as a javascript file or in typescript using ts_project. |
| ts_project( |
| name = "plugin_file", |
| testonly = True, |
| srcs = ["plugin.ts"], |
| extends = ":tsconfig.json", |
| tsconfig = { |
| "compilerOptions": { |
| "types": ["node"], |
| }, |
| }, |
| deps = [ |
| "@yarn//@types/node", |
| "@yarn//express", |
| ], |
| ) |
| |
| # You can write your cypress tests a javascript files or in typescript. |
| ts_project( |
| name = "hello_spec", |
| testonly = True, |
| srcs = ["hello.spec.ts"], |
| extends = ":tsconfig.json", |
| tsconfig = { |
| "compilerOptions": { |
| "types": ["cypress"], |
| }, |
| }, |
| deps = [ |
| "@yarn//cypress", |
| ], |
| ) |
| |
| cypress_web_test( |
| # The name of your test target |
| name = "test", |
| srcs = [ |
| # Load javascript test files directly as sources |
| "world.spec.js", |
| # Load ts_library tests as a target to srcs |
| ":hello_spec", |
| ], |
| # A cypress config file is required |
| config_file = "cypress.json", |
| # Any runtime dependencies you need to boot your server or run your tests |
| data = ["@yarn//rxjs"], |
| # Your cypress plugin used to configure cypress and boot your server |
| plugin_file = ":plugin_file", |
| ) |