-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a package script `test:package`, which performs some basic testing to confirm that a browser-based TypeScript app is able to import the NPM package and use Ably functionality. This hopefully gives us further confidence that we’ve correctly configured the package’s exports and typings. Next, we’ll build on top of this to add similar testing for the tree-shakable version of the library, once we’ve added typings for it in #1442. Some of the approach here is copied from that used for testing the CDN bundle in the Spaces SDK (see commit fa95f9f there). Resolves #1474.
- Loading branch information
1 parent
2d1f433
commit 9f3dabb
Showing
14 changed files
with
2,713 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Test NPM package | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test-npm-package: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: true | ||
- name: Use Node.js 16.x | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 16.x | ||
- run: npm ci | ||
- run: npm run test:package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# ably-js NPM package test (for browser) | ||
|
||
This directory is intended to be used for testing the following aspects of the ably-js NPM package when used in a browser-based app: | ||
|
||
- that its exports are correctly configured and provide access to ably-js’s functionality | ||
- that its TypeScript typings are correctly configured and can be successfully used from a TypeScript-based app that imports the package | ||
|
||
The file `src/index.ts` imports the ably-js package and exports a function which briefly exercises its functionality. | ||
|
||
## Why is `ably` not in `package.json`? | ||
|
||
The `ably` dependency gets added when we run the repository’s `test:bundle` package script. That script copies the contents of this `template` directory to a new temporary directory, and then adds the `ably` dependency to the copy. We do this so that we can check this directory’s `package-lock.json` into Git, without needing to modify it whenever ably-js’s dependencies change. | ||
|
||
## Package scripts | ||
|
||
This directory exposes three package scripts that are to be used for testing: | ||
|
||
- `build`: Uses esbuild to create a bundle containing `src/index.ts` and ably-js. | ||
- `test`: Using the bundle created by `build`, tests that the code that exercises ably-js’s functionality is working correctly in a browser. | ||
- `typecheck`: Type-checks the code that imports ably-js. |
Oops, something went wrong.