Skip to content

Commit fa95f9f

Browse files
Add a script to test the bundle that will be uploaded to CDN
Add a `test:cdn_bundle` NPM script and run it in CI. This script tests the bundle that the `.github/workflows/cdn.yml` workflow will upload to the CDN, by checking that, when this bundle is imported by a web page, it gives access to a working Spaces client. The approach (using Playwright and a local web server powered by Express) is based heavily on that used by the `test:playwright` NPM script in ably-js at commit 83b4516. I then incorporated Dom’s suggestion of using Playwright’s built-in test-running functionality, taking code from his draft PR #218.
1 parent 60a8a0b commit fa95f9f

File tree

18 files changed

+1513
-4
lines changed

18 files changed

+1513
-4
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module.exports = {
4242
extends: ['plugin:jsdoc/recommended'],
4343
},
4444
],
45-
ignorePatterns: ['dist', 'build', 'examples'],
45+
ignorePatterns: ['dist', 'build', 'examples', 'test/ably-common'],
4646
settings: {
4747
jsdoc: {
4848
tagNamePreference: {

.github/workflows/cdn.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,6 @@ jobs:
4545
run: |
4646
npm ci
4747
npm run build
48+
# Note: If you modify what we upload to the CDN, you must make sure you keep the `test:cdn-bundle` NPM script in sync with your changes.
4849
- run: |
4950
aws s3 cp ./dist/iife/index.bundle.js s3://${{ github.event.inputs.bucket }}/spaces/${{ github.event.inputs.version }}/iife/index.bundle.js

.github/workflows/dev-ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,16 @@ jobs:
8080
sourcePath: docs/typedoc/generated
8181
githubToken: ${{ secrets.GITHUB_TOKEN }}
8282
artifactName: typedoc
83+
test-cdn-bundle:
84+
runs-on: ubuntu-latest
85+
steps:
86+
- uses: actions/checkout@v2
87+
with:
88+
submodules: true
89+
- uses: actions/setup-node@v1
90+
with:
91+
node-version: 18
92+
- run: npm ci
93+
- run: npx playwright install chromium
94+
- run: npm run build
95+
- run: npm run test:cdn-bundle

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ node_modules/
66
coverage
77
.env
88
docs/typedoc/generated/
9+
test-results/
910

1011
# Local Netlify folder
1112
.netlify

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "test/ably-common"]
2+
path = test/ably-common
3+
url = https://github.com/ably/ably-common.git

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test/ably-common/

CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,12 @@ To run the Jest tests, simply run the following command:
3434
```bash
3535
npm test
3636
```
37+
38+
### CDN bundle test
39+
40+
To test the bundle that we upload to the CDN:
41+
42+
1. Initialize submodules: `git submodule update --init`
43+
2. Install browser for Playwright to use: `npx run playwright install chromium`
44+
3. Build the bundle: `npm run build`
45+
4. Run the test: `npm run test:cdn-bundle`

0 commit comments

Comments
 (0)