Commit b5dd80a6 authored by Karen Konou's avatar Karen Konou

[Tests] Playwright scaffolding

parent cedf7e8b
Pipeline #7461 passed with stages
in 38 minutes and 28 seconds
......@@ -50,3 +50,9 @@ bundle.js
# IDE specific
.vscode
# Playwright
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
......@@ -54,6 +54,7 @@ test:
script:
- nix --extra-experimental-features "nix-command flakes" run .#compile
- nix --extra-experimental-features "nix-command flakes" run .#test-ps
- nix --extra-experimental-features "nix-command flakes" run .#test-e2e
- nix-collect-garbage --delete-older-than 14d
// @ts-check
import { test, expect } from '@playwright/test';
test('has title', async ({ page }) => {
await page.goto('http://localhost:8008/');
// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/CNRS GarganText/);
});
/*
test('get started link', async ({ page }) => {
await page.goto('https://playwright.dev/');
// Click the get started link.
await page.getByRole('link', { name: 'Get started' }).click();
// Expects page to have a heading with the name of Installation.
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
});
*/
......@@ -138,7 +138,21 @@
echo "Testing"
npm run test
'';
};
};
test-e2e = pkgs.writeShellApplication {
name = "test-e2e";
runtimeInputs = [ compile ] ++ dependencies ++ [ pkgs.playwright-test pkgs.playwright-driver.browsers ];
text = ''
set -e
compile
echo "E2E testing"
export PLAYWRIGHT_BROWSERS_PATH=${pkgs.playwright-driver.browsers}
export PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true
playwright test
'';
};
repl = pkgs.writeShellApplication {
name = "repl";
runtimeInputs = [ compile ] ++ dependencies;
......
// @ts-check
import { defineConfig, devices } from '@playwright/test';
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// import path from 'path';
// dotenv.config({ path: path.resolve(__dirname, '.env') });
/**
* @see https://playwright.dev/docs/test-configuration
*/
export default defineConfig({
testDir: './e2e',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },
/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],
/* Run your local dev server before starting the tests */
webServer: {
command: 'npm run server',
url: 'http://127.0.0.1:8008',
// reuseExistingServer: !process.env.CI,
},
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment