I’m attempting to use the lit testing dependencies in a pure TypeScript project.
So I’ve installed the dependencies like this:
npm i -D @open-wc/testing@latest
npm i -D @web/test-runner
npm i -D @web/test-runner-playwright
npm i -D @web/dev-server
npm i -D @web/dev-server-legacy
and downloaded all the Playwright browsers with:
npx playwright install
The test I’m trying to run looks like this:
import { expect, fixture, html } from "@open-wc/testing";
import { HelloWorldComponent } from "../hello-world.component";
describe("hello-world.component test", () => {
it("works", async () => {
const el: HTMLElement = (await fixture(
html`<hello-world></hello-world> `
)) as HelloWorldComponent;
expect(el).not.to.equal(null);
});
});
When I try to run this it with these test package.json
scripts:
"test": "npm run test:dev && npm run test:prod",
"test:dev": "wtr",
"test:watch": "wtr --watch",
These errors are produced:
???? Browser logs on Chromium:
ReferenceError: describe is not defined
at src/test/hello-world.component.spec.ts:3:0
???? Browser logs on Firefox:
ReferenceError: describe is not defined
at src/test/hello-world.component.spec.ts:3:0
???? Browser logs on Webkit:
ReferenceError: Can't find variable: describe
at module code (src/test/hello-world.component.spec.ts:3:9)
I’m guessing that Mocha needs to be installed as well, and perhaps lit pulls it in as a indirect dependency, because I don’t see it as a direct dependency. Does anyone have any insight?