Skip to content

Commit

Permalink
test: cleanup playwright test code
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtPooki committed Oct 23, 2023
1 parent 386206a commit 153ff64
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 27 deletions.
27 changes: 14 additions & 13 deletions e2e-tests/compare-to-ipfs-io.spec.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
import { test, expect } from '@playwright/test'
import { PORT } from '../src/constants.js'

test.setTimeout(120000)

// test all the same pages listed at https://probelab.io/websites/
const pages = [
'/ipns/blog.ipfs.tech',
// '/ipns/blog.ipfs.tech', // currently timing out for Helia.
'/ipns/blog.libp2p.io',
'/ipns/consensuslab.world',
'/ipns/docs.ipfs.tech',
'/ipns/docs.libp2p.io',
'/ipns/drand.love',
'/ipns/fil.org',
'/ipns/filecoin.io',
// '/ipns/fil.org', // currently timing out for Helia.
// '/ipns/filecoin.io', // currently timing out for Helia.
'/ipns/green.filecoin.io',
'/ipns/ipfs.tech',
// '/ipns/ipfs.tech', // currently timing out for Helia.
'/ipns/ipld.io',
'/ipns/libp2p.io',
'/ipns/n0.computer',
// '/ipns/n0.computer', // currently timing out for Helia.
'/ipns/probelab.io',
'/ipns/protocol.ai',
'/ipns/research.protocol.ai',
'/ipns/protocol.ai', // very slow, but can pass.
'/ipns/research.protocol.ai', // slow-ish, but can pass.
'/ipns/singularity.storage',
'/ipns/specs.ipfs.tech',
'/ipns/strn.network',
'/ipns/web3.storage'
'/ipns/strn.network'
// '/ipns/web3.storage' // currently timing out for Helia
]

// don't bombard helia-gateway with parallel requests. it's not ready for that yet
test.describe.configure({ mode: 'serial' })
// don't bombard Helia gateway with parallel requests. It's not ready for that yet
// test.describe.configure({ mode: 'serial' })

// increase default test timeout to 2 minutes
test.setTimeout(120000)

// now for each page, make sure we can request the website, the content is not empty, and status code is 200
pages.forEach((pagePath) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"start": "node dist/src/index.js",
"start:dev": "npm run build && node dist/src/index.js",
"test": "echo \"Error: no test specified\" && exit 1",
"test:e2e": "playwright test --max-failures 5",
"test:e2e": "playwright test",
"healthcheck": "node dist/src/healthcheck.js"
},
"type": "module",
Expand Down
25 changes: 13 additions & 12 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { defineConfig, devices } from '@playwright/test';

import {PORT} from './src/constants.js'
import { defineConfig, devices } from '@playwright/test'
import { PORT } from './src/constants.js'

/**
* Read environment variables from file.
Expand All @@ -16,11 +15,11 @@ export default defineConfig({
/* 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,
forbidOnly: Boolean(process.env.CI),
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
retries: (process.env.CI != null) ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
workers: (process.env.CI != null) ? 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. */
Expand All @@ -29,15 +28,16 @@ export default defineConfig({
// 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',
trace: 'on-first-retry'
},
maxFailures: 5,

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
use: { ...devices['Desktop Chrome'] }
}

// {
// name: 'firefox',
Expand All @@ -55,6 +55,7 @@ export default defineConfig({
webServer: {
command: 'npm run start:dev',
url: `http://localhost:${PORT}`,
reuseExistingServer: !process.env.CI,
},
});
// Tiros does not re-use the existing server.
reuseExistingServer: process.env.CI == null
}
})
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"include": [
"src",
"test",
"e2e-tests"
"e2e-tests",
"playwright.config.ts"
]
}

0 comments on commit 153ff64

Please sign in to comment.