All tests being executed once after I opened my project (using vitest) in vscode, how can I disable this feature? #398
Replies: 2 comments 4 replies
-
Do you mean, the tests use playwright CLI, or do you use Vitest to initiate playwright instance? Can you give any code examples? The extension shouldn't start any |
Beta Was this translation helpful? Give feedback.
1 reply
-
Here is my vitest.config.js file (it'll start test site server once import { defineConfig } from "vite";
import { exec } from "child_process";
export default defineConfig(async () => {
// start test site server, note that this is also being executed when project opened, which is undesirable behavior
exec("yarn dev");
return {
test: {
environment: "jsdom"
}
};
}); And here is one of my e2e test file (simplified): import { afterAll, beforeAll, describe, test} from "vitest";
import { Browser, Page, chromium } from "@playwright/test";
describe("sample e2e tests", () => {
let browser: Browser;
let page: Page;
beforeAll(async () => {
browser = await chromium.launch({ headless: false, args: ["--start-maximized"] });
page = await browser.newPage({
viewport: null
});
await page.goto("http://localhost:5173"); // goto test site
});
afterAll(async () => {
await browser.close();
});
const testSteps = async () => {
await page.waitForTimeout(2000);
const cards = await page.locator(".cards").all();
const bx0 = await cards[0].boundingBox();
const bx1 = await cards[1].boundingBox();
expect(Math.abs(bx0!.x + bx0!.width - bx1!.x)).toBeLessThan(1);
};
test("layout test", { timeout: 10000 }, async () => {
await testSteps();
});
}); Some of
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm also using playwright as my e2e test helper, every time project's being opened, the extension will execute all tests thus opening automated browser, which is annoying. Can I turn off this feature?
P.S. I'm not talking about enabling headless mode for e2e test.
Beta Was this translation helpful? Give feedback.
All reactions