diff --git a/packages/testing-kit/package.json b/packages/testing-kit/package.json index c1d9f41eea..b452bfd07d 100644 --- a/packages/testing-kit/package.json +++ b/packages/testing-kit/package.json @@ -16,7 +16,9 @@ "url": "git+https://github.com/mondaycom/vibe.git" }, "scripts": { - "test": "node ./__tests__/testing-kit.test.js" + "test": "npx playwright test", + "build": "tsc", + "start-server": "cd .. && cd core && yarn storybook" }, "bugs": { "url": "https://github.com/mondaycom/vibe/issues" diff --git a/packages/testing-kit/playwright.config.ts b/packages/testing-kit/playwright.config.ts index c7daddfb2b..251d6a9b84 100644 --- a/packages/testing-kit/playwright.config.ts +++ b/packages/testing-kit/playwright.config.ts @@ -10,6 +10,15 @@ module.exports = defineConfig({ fullyParallel: false, workers: 1, reporter: [["html", { open: "never", outputFolder: path.join(__dirname, "/reports") }]], + // Run your local dev server before starting the tests + webServer: { + command: 'yarn start-server', + url: 'http://127.0.0.1:7008', + reuseExistingServer: !process.env.CI, + timeout: 120 * 1000, + stdout: 'ignore', + stderr: 'ignore', + }, use: { headless: true, baseURL: "http://127.0.0.1:7008", diff --git a/packages/testing-kit/src/__TESTS__/button.spec.js b/packages/testing-kit/src/__TESTS__/button.spec.js index 4e35c53949..ab87a3cf98 100644 --- a/packages/testing-kit/src/__TESTS__/button.spec.js +++ b/packages/testing-kit/src/__TESTS__/button.spec.js @@ -4,11 +4,18 @@ import { Button } from '../buttons/Button'; // Assuming you have this Button cl test('should fire a click event and log to console', async ({ page }) => { // Navigate to the Storybook page with the component await page.goto('/?path=/story/buttons-button--overview'); - // Locate the iframe where the button is rendered const frame = page.frameLocator("[id='storybook-preview-iframe']"); const button = new Button(page, frame.locator('button[data-testid="button"]'), 'Button'); - + + //TODO - find a better way to wait for the storybook to load + while (await button.locator.isVisible() === false) { + await page.waitForTimeout(30000); + await page.reload(); + if (await button.locator.isVisible() === true) { + break; + } + } // Add a listener to capture console logs let consoleMessage = ''; page.on('console', async (msg) => { diff --git a/packages/testing-kit/src/__TESTS__/textfield.spec.js b/packages/testing-kit/src/__TESTS__/textfield.spec.js index 7029fe3dba..dec104b6cf 100644 --- a/packages/testing-kit/src/__TESTS__/textfield.spec.js +++ b/packages/testing-kit/src/__TESTS__/textfield.spec.js @@ -1,7 +1,6 @@ import { test, expect } from "@playwright/test"; import { TextField } from "../inputs/TextField"; -test.use({ headless: false }); test.describe("textArea Class with Storybook", () => { let textField; let textfieldLocator