Skip to content

Commit

Permalink
test(e2e): allow more flexibility with env vars for e2e tests (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtPooki authored Dec 6, 2023
1 parent 23f467f commit 70c597a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
9 changes: 0 additions & 9 deletions e2e-tests/smoketest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ test.beforeEach(async ({ context }) => {
await context.route(/.(css|js|svg|png|jpg|woff2|otf|webp|ttf|json)(?:\?.*)?$/, async route => route.abort())
})

test.afterEach(async ({ page }) => {
test.setTimeout(2 * 60 * 1000) // 2 minutes
const result = await page.request.post(`http://localhost:${PORT}/api/v0/repo/gc`)
expect(result?.status()).toBe(200)

const maybeContent = await result?.text()
expect(maybeContent).toEqual('OK')
})

pages.forEach((pagePath) => {
const url = `http://${pagePath}.ipns.localhost:${PORT}`
test(`helia-http-gateway can load path '${url}'`, async ({ page }) => {
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"lint": "aegir lint",
"build": "aegir build --bundle false",
"start": "node --trace-warnings dist/src/index.js",
"start:env-dr": "node -r dotenv/config --trace-warnings dist/src/index.js dotenv_config_path=./.env-delegated-routing",
"start:env-to": "node -r dotenv/config --trace-warnings dist/src/index.js dotenv_config_path=./.env-trustless-only",
"start:dev": "npm run build && node dist/src/index.js",
"start:dev-trace": "npm run build && node --trace-warnings dist/src/index.js",
"start:dev-doctor": "npm run build && npx clinic doctor --name playwright -- node dist/src/index.js",
Expand Down
11 changes: 9 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import { join } from 'node:path'
import { defineConfig, devices } from '@playwright/test'
import { PORT } from './src/constants.js'

/**
* Run one of the variants of `npm run start` by setting the PLAYWRIGHT_START_CMD_MOD environment variable.
*
* For example, to run `npm run start:dev-doctor`: `PLAYWRIGHT_START_CMD_MOD=:dev-doctor npm run test:e2e`
* For example, to run `npm run start:env-to`: `PLAYWRIGHT_START_CMD_MOD=:env-to npm run test:e2e`
*/
const PLAYWRIGHT_START_CMD_MOD = process.env.PLAYWRIGHT_START_CMD_MOD ?? ''

/**
* See https://playwright.dev/docs/test-configuration.
*/
Expand Down Expand Up @@ -51,13 +59,12 @@ export default defineConfig({

/* Run your local dev server before starting the tests */
webServer: {
command: (process.env.DOCTOR != null) ? 'npm run start:dev-doctor' : 'npm run start:dev',
command: `npm run build && npm run start${PLAYWRIGHT_START_CMD_MOD}`,
port: PORT,
// Tiros does not re-use the existing server.
reuseExistingServer: process.env.CI == null,
env: {
DEBUG: process.env.DEBUG ?? ' ',
USE_BITSWAP: 'false',
// we save to the filesystem so github CI can cache the data.
FILE_BLOCKSTORE_PATH: join(process.cwd(), 'test', 'fixtures', 'e2e', 'blockstore'),
FILE_DATASTORE_PATH: join(process.cwd(), 'test', 'fixtures', 'e2e', 'datastore')
Expand Down

0 comments on commit 70c597a

Please sign in to comment.