Skip to content

Commit 9bef15b

Browse files
committed
tests: add integration test for webpack example
1 parent bca92d2 commit 9bef15b

File tree

9 files changed

+52
-5
lines changed

9 files changed

+52
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
/typings
1616
/test-results
1717
/playwright-report
18+
/graphql-voyager-*.tgz

docker-compose.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@ services:
99
- ./worker-dist:/home/worker-dist
1010
stdin_open: true
1111
tty: true
12+
serve-webpack-example:
13+
build:
14+
context: .
15+
dockerfile: ./example/webpack/Dockerfile
16+
stdin_open: true
17+
tty: true
1218
test:
19+
depends_on:
20+
- serve-webpack-example
1321
build:
1422
context: .
1523
dockerfile: ./tests/Dockerfile

example/webpack/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM node:18
4+
5+
WORKDIR /app
6+
7+
COPY ./graphql-voyager-*.tgz graphql-voyager.tgz
8+
9+
COPY ./example/webpack ./example/webpack
10+
11+
WORKDIR example/webpack
12+
RUN npm install
13+
# FIXME
14+
# RUN npm test
15+
16+
EXPOSE 9091
17+
CMD npm start

example/webpack/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
},
88
"dependencies": {
99
"graphql": "16.5.0",
10-
"graphql-voyager": "1.0.1",
11-
"react": "18.2.0",
12-
"react-dom": "18.2.0"
10+
"graphql-voyager": "../../graphql-voyager.tgz",
11+
"react": "18.2.0"
1312
},
1413
"devDependencies": {
1514
"@types/react": "^18.0.29",

example/webpack/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ const path = require('node:path');
22

33
module.exports = {
44
devServer: {
5-
https: true,
65
port: 9090,
6+
allowedHosts: 'all',
77
static: {
88
directory: __dirname,
99
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"prettier": "prettier --cache --write --list-different . **/*.svg",
3737
"prettier:check": "prettier --cache --check . **/*.svg",
3838
"check:spelling": "cspell --cache --no-progress '**/*'",
39-
"testonly": "npm run build:demo && docker-compose up --abort-on-container-exit --build test",
39+
"testonly": "npm run build:demo && npm pack && docker-compose up --abort-on-container-exit --build test",
4040
"declarations": "tsc --emitDeclarationOnly -p tsconfig.lib.json"
4141
},
4242
"peerDependencies": {

playwright.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ const config: PlaywrightTestConfig = {
4747
baseURL: 'http://localhost:9090',
4848
},
4949
},
50+
{
51+
name: 'WebpackExample',
52+
testMatch: 'webpack.spec.ts',
53+
use: {
54+
...devices['Desktop Chrome'],
55+
trace: 'on',
56+
viewport: { width: 1920, height: 1001 },
57+
58+
/* Base URL to use in actions like `await page.goto('/')`. */
59+
baseURL: 'http://serve-webpack-example:9090',
60+
},
61+
},
5062
],
5163
outputDir: 'test-results/',
5264
webServer: {

tests/webpack.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { expect, test } from '@playwright/test';
2+
3+
import { gotoVoyagerPage } from './PageObjectModel';
4+
5+
test('open webpack example', async ({ page }) => {
6+
const voyagerPage = await gotoVoyagerPage(page);
7+
8+
await voyagerPage.waitForGraphToBeLoaded();
9+
await expect(voyagerPage.page).toHaveScreenshot('loaded-webpack-example.png');
10+
});
391 KB
Loading

0 commit comments

Comments
 (0)