3

Is it possible to split one big cypress file with one big integration test suite and move source parts to couple files. In this big suite I have several test-cases. I want to move every test case to another file but it is required to create one big integration test. I need record one movie of tests after run.

MarcinW
  • 51
  • 6
  • If your goal is to have one video, you can merge all videos together which would be much better I think than to have one suite that executes dozens of tests. Or you can split your test suites into multiple files and export every `describe` as function and call those function in one single test suite – Josef Biehler Dec 16 '19 at 11:31

1 Answers1

4

You can import tests as functions, my company is doing this in a couple repos.

In your original test file:

import { test1 } from "./test1";
import { test2 } from "./test2";

describe("Test suite", () => {
  test1();
  test2();
});

In cypress/integration/test1:

export function test1 {
  it("Can do something", () => {
    // test goes here
  });
}

In cypress/integration/test2:

export function test2 {
  it("Can do something else", () => {
    // test goes here
  });
}
Brendan
  • 4,327
  • 1
  • 23
  • 33