Skip to content

Commit

Permalink
tests: add integration test for webpack example (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov authored May 27, 2023
1 parent bca92d2 commit 4414832
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
/typings
/test-results
/playwright-report
/graphql-voyager-*.tgz
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ services:
- ./worker-dist:/home/worker-dist
stdin_open: true
tty: true
serve-webpack-example:
build:
context: .
dockerfile: ./example/webpack/Dockerfile
stdin_open: true
tty: true
test:
depends_on:
- serve-webpack-example
build:
context: .
dockerfile: ./tests/Dockerfile
Expand Down
17 changes: 17 additions & 0 deletions example/webpack/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# syntax=docker/dockerfile:1

FROM node:18

WORKDIR /app

COPY ./graphql-voyager-*.tgz graphql-voyager.tgz

COPY ./example/webpack ./example/webpack

WORKDIR example/webpack
RUN npm install
# FIXME
# RUN npm test

EXPOSE 9091
CMD npm start
5 changes: 2 additions & 3 deletions example/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
},
"dependencies": {
"graphql": "16.5.0",
"graphql-voyager": "1.0.1",
"react": "18.2.0",
"react-dom": "18.2.0"
"graphql-voyager": "../../graphql-voyager.tgz",
"react": "18.2.0"
},
"devDependencies": {
"@types/react": "^18.0.29",
Expand Down
2 changes: 1 addition & 1 deletion example/webpack/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const path = require('node:path');

module.exports = {
devServer: {
https: true,
port: 9090,
allowedHosts: 'all',
static: {
directory: __dirname,
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"prettier": "prettier --cache --write --list-different . **/*.svg",
"prettier:check": "prettier --cache --check . **/*.svg",
"check:spelling": "cspell --cache --no-progress '**/*'",
"testonly": "npm run build:demo && docker-compose up --abort-on-container-exit --build test",
"testonly": "npm run build:demo && npm pack && docker-compose up --abort-on-container-exit --build test",
"declarations": "tsc --emitDeclarationOnly -p tsconfig.lib.json"
},
"peerDependencies": {
Expand Down
12 changes: 12 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ const config: PlaywrightTestConfig = {
baseURL: 'http://localhost:9090',
},
},
{
name: 'WebpackExample',
testMatch: 'webpack.spec.ts',
use: {
...devices['Desktop Chrome'],
trace: 'on',
viewport: { width: 1920, height: 1001 },

/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: 'http://serve-webpack-example:9090',
},
},
],
outputDir: 'test-results/',
webServer: {
Expand Down
10 changes: 10 additions & 0 deletions tests/webpack.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { expect, test } from '@playwright/test';

import { gotoVoyagerPage } from './PageObjectModel';

test('open webpack example', async ({ page }) => {
const voyagerPage = await gotoVoyagerPage(page);

await voyagerPage.waitForGraphToBeLoaded();
await expect(voyagerPage.page).toHaveScreenshot('loaded-webpack-example.png');
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4414832

Please sign in to comment.