jeudi 15 octobre 2020

TestCafe "fixture is not defined" error when importing fixture and tests from multiple files into main.js file

I am unable to import tests and a fixture into one main.ts file to run all my tests at once. For organization purposes, I have my tests organized into separate folders. I am getting the error:

ERROR Cannot prepare tests due to an error.
ReferenceError: fixture is not defined

I've created a main.ts file to run all my tests. I import Fixture(), Test1() and Test2().

main.ts

import { Fixture } from "../utils/envUtils";
import { Test1 } from "./testSet1/test1";
import { Test2 } from "./testSet2/test2";

Fixture();
Test1();
Test2();

Fixture.ts

export const Fixture = () => {
    fixture("Running tests")
}

Test1.ts

export function Test1() {
    test("Test1", async (t: TestController) => {
         ...
    }
}

Test2.ts

export function Test2() {
    test("Test2", async (t: TestController) => {
         ...
    }
}

If I manually copy and paste the Test1() and Test2() code into the main.ts file, it works. Any help is appreciated. Thanks!

Aucun commentaire:

Enregistrer un commentaire