Skip to content

Commit

Permalink
feat: initialize & configure playwright, and write a single regressio…
Browse files Browse the repository at this point in the history
…n/smoke test (#1547)

* feat: install playwright

* feat: add a single smoke test against production
  • Loading branch information
pepopowitz authored Dec 6, 2022
1 parent f3e66f1 commit 0da2e79
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ yarn-debug.log*
yarn-error.log*
node_modules
/camunda-cloud-documentation.iml
/test-results/
/playwright-report/
/playwright/.cache/
71 changes: 71 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"format:check": "prettier --check .",
"prepare": "husky install",
"test": "jest",
"test:regression": "playwright test spec/",
"test:watch": "jest --watch"
},
"dependencies": {
Expand Down Expand Up @@ -47,9 +48,11 @@
]
},
"devDependencies": {
"@playwright/test": "^1.28.0",
"husky": "^8.0.1",
"jest": "^29.3.1",
"lint-staged": "^13.0.3",
"playwright": "^1.28.0",
"prettier": "2.7.1"
},
"lint-staged": {
Expand Down
108 changes: 108 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import type { PlaywrightTestConfig } from "@playwright/test";
import { devices } from "@playwright/test";

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
const config: PlaywrightTestConfig = {
testDir: "./spec",
/* Maximum time one test can run for. */
timeout: 30 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 5000,
},
/* 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: "list",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://localhost:3000',
baseURL: "https://docs.camunda.io",

/* 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"],
// },
// },

// {
// name: 'firefox',
// use: {
// ...devices['Desktop Firefox'],
// },
// },

// {
// name: 'webkit',
// use: {
// ...devices['Desktop Safari'],
// },
// },

/* 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: {
// channel: 'msedge',
// },
// },
// {
// name: 'Google Chrome',
// use: {
// channel: 'chrome',
// },
// },
// ],

/* Folder for test artifacts such as screenshots, videos, traces, etc. */
// outputDir: 'test-results/',

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// port: 3000,
// },
};

export default config;
12 changes: 12 additions & 0 deletions spec/regression/smoke.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { test, expect } from "@playwright/test";

test("homepage has title and links to intro page", async ({ page }) => {
await page.goto("/");

await expect(page).toHaveTitle(
/Camunda Platform 8 Docs \| Camunda Platform 8 Docs/
);
await expect(page.locator("h1.hero__title")).toHaveText(
"Camunda Platform 8 Docs"
);
});

0 comments on commit 0da2e79

Please sign in to comment.