Skip to content

Commit

Permalink
Add integration tests
Browse files Browse the repository at this point in the history
This adds integration tests that test the core functionality of the SDK.

I had originally written these as a single `describe` containing four
`it`s, each of which included the test setup and then a list of
scenarios, these scenarios just being separated by comments. However,
Dom was keen for me to make more use of the vitest APIs for structuring
my tests. This resulted in the current setup, where there is one
`describe` for each area of functionality, each of these `describe`s
then containing multiple `it`s. Each `it` within a given `describe`
relies on the side effects of the previous `it`s within that `describe`.

Dom preferred this new approach and was happy to accept the compromises
that this resulted in, such as having `describe`-level local variables
which have no type information, and the fact that the failure of one
`it` does not prevent the subsequent `it`s (which rely on the
preceding `it`s all having succeeded) from running.

With my initial approach, I was able to get the tests running in
parallel using `describe.concurrent` on the top-level `describe`. I
wasn’t able to figure out how to achieve this in the new approach, in
which we want to run all `describe`s in parallel, but run the `it`s
within a given `describe` sequentially. I tried using `.concurrent` on
the top-level `describe` and `.sequential` on each nested `describe`,
but it still just ran everything sequentially.

Resolves COL-56.
  • Loading branch information
lawrence-forooghian committed Oct 30, 2023
1 parent dac823f commit a2b0d08
Show file tree
Hide file tree
Showing 4 changed files with 661 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/dev-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-node@v1
with:
node-version: 18
Expand Down
17 changes: 13 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@

## Test suite

### Setup

Before running the tests, you first need to initialize the repository’s submodules:

```
git submodule update --init
```

### Running the tests

To run the Jest tests, simply run the following command:

```bash
Expand All @@ -39,7 +49,6 @@ npm test

To test the bundle that we upload to the CDN:

1. Initialize submodules: `git submodule update --init`
2. Install browser for Playwright to use: `npx run playwright install chromium`
3. Build the bundle: `npm run build`
4. Run the test: `npm run test:cdn-bundle`
1. Install browser for Playwright to use: `npx run playwright install chromium`
2. Build the bundle: `npm run build`
3. Run the test: `npm run test:cdn-bundle`
Loading

0 comments on commit a2b0d08

Please sign in to comment.