Skip to content

Commit 32d4092

Browse files
committed
chore: add multi platform browser tests
1 parent 378894d commit 32d4092

5 files changed

Lines changed: 91 additions & 9 deletions

File tree

.github/workflows/push.yml

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,10 @@ jobs:
3030
.rdf-test-suite-cache
3131
.rdf-test-suite-ldf-cache
3232
key: ${{ runner.os }}-test-modules-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/yarn.lock') }}
33-
- name: Install dependencies
33+
- name: Install dependencies & build
3434
run: yarn install --pure-lockfile
35-
- name: Build project
36-
run: yarn run build
3735
- name: Run depcheck
3836
run: yarn run depcheck
39-
- name: Run browser-tests
40-
run: yarn run test-browser
4137
- name: Run tests
4238
run: yarn run test-ci
4339
- name: Submit coverage results
@@ -47,6 +43,47 @@ jobs:
4743
flag-name: run-${{ matrix.node-version }}
4844
parallel: true
4945

46+
test-browser:
47+
name: Browser tests
48+
strategy:
49+
fail-fast: false
50+
matrix:
51+
browser:
52+
- Chrome
53+
- Firefox
54+
- Webkit
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Ensure line endings are consistent
58+
run: git config --global core.autocrlf input
59+
- name: Check out repository
60+
uses: actions/checkout@v3
61+
- name: Use Node.js ${{ matrix.node-version }}
62+
uses: actions/setup-node@v3
63+
with:
64+
node-version: ${{ matrix.node-version }}
65+
- name: Load cache
66+
uses: actions/cache@v4
67+
with:
68+
path: |
69+
**/node_modules
70+
key: ${{ runner.os }}-test-modules-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/yarn.lock') }}
71+
- name: Install dependencies & build
72+
run: yarn install --pure-lockfile
73+
- name: Install ${{ matrix.browser }} via Playwright
74+
if: startsWith(matrix.browser, 'Webkit')
75+
# The @L will convert 'Webkit' into lowercase 'webkit' which is the name Playwright expects.
76+
run: yarn playwright install --with-deps ${BROWSER_NAME@L}
77+
env:
78+
BROWSER_NAME: ${{ matrix.browser }}
79+
- name: Run browser tests
80+
uses: nick-fields/retry@v3
81+
with:
82+
timeout_minutes: 2
83+
max_attempts: 3
84+
# The tests will run on 'WebkitHeadless', 'FirefoxHeadless' and 'ChromeHeadless'
85+
command: yarn run test-browser --browsers ${{ matrix.browser }}Headless
86+
5087
coveralls:
5188
needs: test
5289
runs-on: ubuntu-latest
@@ -78,6 +115,7 @@ jobs:
78115
docs:
79116
needs:
80117
- test
118+
- test-browser
81119
- lint
82120
if: github.ref == 'refs/heads/master'
83121
runs-on: ubuntu-latest

karma.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
const Path = require('node:path');
1+
const webkit = require('@playwright/test').webkit;
22
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
33
const webpack = require('webpack');
44

55
const testFiles = [
66
'engines/query-sparql-incremental/test-browser/QuerySparql-test.ts',
77
];
88

9+
process.env.WEBKIT_HEADLESS_BIN = webkit.executablePath();
10+
911
// Based on https://github.com/tom-sherman/blog/blob/main/posts/02-running-jest-tests-in-a-browser.md
1012
module.exports = function(config) {
1113
config.set({
@@ -15,6 +17,7 @@ module.exports = function(config) {
1517
'karma-jasmine',
1618
'karma-chrome-launcher',
1719
'karma-firefox-launcher',
20+
'karma-webkit-launcher',
1821
'karma-sourcemap-loader',
1922
'karma-jasmine-html-reporter',
2023
],
@@ -36,7 +39,6 @@ module.exports = function(config) {
3639
alias: {
3740
fs: false,
3841
module: false,
39-
[Path.resolve(__dirname, 'engines/query-sparql-incremental/test/util.js')]: Path.resolve(__dirname, 'engines/query-sparql-incremental/test-browser/util-browser.js'),
4042
'jest.unmock': false,
4143
},
4244
extensions: [ '.js', '.jsx', '.ts', '.tsx' ],
@@ -91,6 +93,7 @@ module.exports = function(config) {
9193
browsers: [
9294
'ChromeHeadless',
9395
'FirefoxHeadless',
96+
'WebkitHeadless',
9497
],
9598
});
9699
};

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"devDependencies": {
4141
"@comunica/utils-jest": "^4.0.1",
4242
"@comunica/utils-monorepo": "^4.0.1",
43+
"@playwright/test": "^1.47.2",
4344
"@rubensworks/eslint-config": "^3.0.0",
4445
"@types/jest": "^29.0.0",
4546
"@types/md5": "^2.3.5",
@@ -60,6 +61,7 @@
6061
"karma-jasmine": "^5.1.0",
6162
"karma-jasmine-html-reporter": "^2.0.0",
6263
"karma-sourcemap-loader": "^0.4.0",
64+
"karma-webkit-launcher": "^2.6.0",
6365
"karma-webpack": "^5.0.0",
6466
"lerna": "^7.4.2",
6567
"lerna-script": "^1.4.0",

run-browser-tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ function endServers() {
162162

163163
// eslint-disable-next-line no-console
164164
console.log('Starting Karma tests:');
165-
const lsProcess = spawn('karma', [ 'start', 'karma.config.js', '--single-run' ]);
165+
const lsProcess = spawn('karma', [ 'start', 'karma.config.js', '--single-run', ...process.argv.splice(2) ]);
166166
lsProcess.stdout.on('data', (data) => {
167167
process.stdout.write(data);
168168
});

yarn.lock

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3970,6 +3970,13 @@
39703970
resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.1.tgz#1ec17e2edbec25c8306d424ecfbf13c7de1aaa31"
39713971
integrity sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==
39723972

3973+
"@playwright/test@^1.47.2":
3974+
version "1.50.1"
3975+
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.50.1.tgz#027d00ca77ec79688764eb765cfe9a688807bf0b"
3976+
integrity sha512-Jii3aBg+CEDpgnuDxEp/h7BimHcUTDlpEtce89xEumlJ5ef2hqepZ+PWp1DDpYC/VO9fmWVI1IlEaoI5fK9FXQ==
3977+
dependencies:
3978+
playwright "1.50.1"
3979+
39733980
"@rdfjs/types@*", "@rdfjs/types@1.1.2", "@rdfjs/types@^1.1.0", "@rdfjs/types@^2.0.0":
39743981
version "1.1.2"
39753982
resolved "https://registry.yarnpkg.com/@rdfjs/types/-/types-1.1.2.tgz#9c2f9848c44c26d383bed2a808571de3b93b808d"
@@ -8145,6 +8152,11 @@ fs.realpath@^1.0.0:
81458152
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
81468153
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==
81478154

8155+
fsevents@2.3.2:
8156+
version "2.3.2"
8157+
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
8158+
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
8159+
81488160
fsevents@^2.3.2, fsevents@~2.3.2:
81498161
version "2.3.3"
81508162
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6"
@@ -9134,7 +9146,7 @@ is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.2.7:
91349146
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055"
91359147
integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==
91369148

9137-
is-ci@3.0.1:
9149+
is-ci@3.0.1, is-ci@^3.0.1:
91389150
version "3.0.1"
91399151
resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-3.0.1.tgz#db6ecbed1bd659c43dac0f45661e7674103d1867"
91409152
integrity sha512-ZYvCgrefwqoQ6yTyYUbQu64HsITZ3NfKX1lzaEYdkTDcfKzzCI/wthRRYKkdjHKFVgNiXKAKm65Zo1pk2as/QQ==
@@ -10223,6 +10235,14 @@ karma-sourcemap-loader@^0.4.0:
1022310235
dependencies:
1022410236
graceful-fs "^4.2.10"
1022510237

10238+
karma-webkit-launcher@^2.6.0:
10239+
version "2.6.0"
10240+
resolved "https://registry.yarnpkg.com/karma-webkit-launcher/-/karma-webkit-launcher-2.6.0.tgz#2e3ba096b69139e608d9ce6e89816a17f358b700"
10241+
integrity sha512-IDURopxJ1SbuqnvPaE+lP2qiP2Ie7I+ojwJRBpr0tfGwObsaVdjMkUkmZ1BcXUtYRt5ogs9cyCH2Wb9sNv0BbQ==
10242+
dependencies:
10243+
is-ci "^3.0.1"
10244+
uuid "^10.0.0"
10245+
1022610246
karma-webpack@^5.0.0:
1022710247
version "5.0.0"
1022810248
resolved "https://registry.yarnpkg.com/karma-webpack/-/karma-webpack-5.0.0.tgz#2a2c7b80163fe7ffd1010f83f5507f95ef39f840"
@@ -12176,6 +12196,20 @@ pkg-types@^1.0.3, pkg-types@^1.2.0:
1217612196
mlly "^1.7.2"
1217712197
pathe "^1.1.2"
1217812198

12199+
playwright-core@1.50.1:
12200+
version "1.50.1"
12201+
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.50.1.tgz#6a0484f1f1c939168f40f0ab3828c4a1592c4504"
12202+
integrity sha512-ra9fsNWayuYumt+NiM069M6OkcRb1FZSK8bgi66AtpFoWkg2+y0bJSNmkFrWhMbEBbVKC/EruAHH3g0zmtwGmQ==
12203+
12204+
playwright@1.50.1:
12205+
version "1.50.1"
12206+
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.50.1.tgz#2f93216511d65404f676395bfb97b41aa052b180"
12207+
integrity sha512-G8rwsOQJ63XG6BbKj2w5rHeavFjy5zynBA9zsJMMtBoe/Uf757oG12NXz6e6OirF7RCrTVAKFXbLmn1RbL7Qaw==
12208+
dependencies:
12209+
playwright-core "1.50.1"
12210+
optionalDependencies:
12211+
fsevents "2.3.2"
12212+
1217912213
please-upgrade-node@^3.2.0:
1218012214
version "3.2.0"
1218112215
resolved "https://registry.yarnpkg.com/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz#aeddd3f994c933e4ad98b99d9a556efa0e2fe942"
@@ -14656,6 +14690,11 @@ utils-merge@1.0.1:
1465614690
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
1465714691
integrity sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==
1465814692

14693+
uuid@^10.0.0:
14694+
version "10.0.0"
14695+
resolved "https://registry.yarnpkg.com/uuid/-/uuid-10.0.0.tgz#5a95aa454e6e002725c79055fd42aaba30ca6294"
14696+
integrity sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==
14697+
1465914698
uuid@^9.0.0:
1466014699
version "9.0.1"
1466114700
resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30"

0 commit comments

Comments
 (0)