Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add puppeteer end-to-end integration test #807

Merged
merged 5 commits into from
Apr 29, 2022
Merged

Conversation

ix5
Copy link
Member

@ix5 ix5 commented Mar 3, 2022

This PR adds end-to-end tests on top of #801.

Terminology

  • Jest is a Javascript testing framework. It is mainly used here for unit tests.
  • Puppeteer is a way of having a (headless) browser available for testing (via "browser instrumentation") and to simulate a user clicking on a link, pressing keys or manipulating DOM elements.

The puppeteer integration into Jest is done via the jest-puppeteer plugin, as recommended in Jest: Using with puppeteer.

Note: Installing puppeteer via npm auto-downloads an instance of Chromium into node_modules/puppeteer/.local-chromium, which is around 400MB large!
There might a way to disable this which I haven't bothered to find yet. Also, you might be able to define the browser used, e.g. /usr/bin/chromium instead of the auto-download. Even Firefox seems to be supported.

Running

You need to have a working Isso instance running on localhost:8080 in order for the end-to-end integration tests using puppeteer to work.

Install the needed packages:

npm install jest-puppeteer puppeteer

(I might add those to package.json at some point, but the caveat of the chromium 400MB automatic download applies)

Then run:

  • npm run test-unit for Jest unit tests
  • npm run test-integration for puppeteer browser automation

Highly WIP at the moment, but could be useful to someone else working on the same issues. Please communicate and collaborate!

Depends on #800. I have temporarily changed the base to that branch to make it easier to review this change.

@ix5 ix5 mentioned this pull request Mar 3, 2022
@ix5 ix5 added this to the 0.13 milestone Mar 6, 2022
@ix5 ix5 added client (Javascript) client code and CSS feature labels Mar 6, 2022
@ix5 ix5 deleted the branch isso-comments:master March 29, 2022 21:50
@ix5 ix5 closed this Mar 29, 2022
@ix5 ix5 reopened this Apr 16, 2022
@ix5 ix5 changed the base branch from js-webpack to master April 16, 2022 19:58
@ix5 ix5 marked this pull request as draft April 16, 2022 19:59
ix5 added 4 commits April 29, 2022 20:05
Use comment stanzas above Jest unit tests that explicitly
need the `jsdom` `testEnvironment`.

Add `jest-environment-jsdom` package to `package.json`
because it is now explicitly needed.
Necessitated by updated `jest` and added
`jest-environment-jsdom` packages.
This should speed up a few testing steps and save bandwidth
Since the demo is also reachable at `http://localhost:8080`,
add the origin to allowed hosts to allow easier testing.
@ix5 ix5 marked this pull request as ready for review April 29, 2022 18:27
@ix5 ix5 force-pushed the js-puppeteer branch 3 times, most recently from 244848e to 15f22f6 Compare April 29, 2022 18:36
This is a baseline integration with more to come.

To be run with:
```sh
$ npm install jest-puppeteer
$ npm run test-integration
```

Needs an Isso dev server at `http://localhost:8080` (or
accepts a valid env var `ISSO_ENDPOINT` instead)
@ix5 ix5 force-pushed the js-puppeteer branch 4 times, most recently from b26952f to b3244fb Compare April 29, 2022 19:18
@ix5 ix5 changed the title [WIP] Add puppeteer end-to-end integration test Add puppeteer end-to-end integration test Apr 29, 2022
@ix5 ix5 merged commit aaa9de1 into isso-comments:master Apr 29, 2022
@ix5 ix5 deleted the js-puppeteer branch April 29, 2022 19:21
@ix5 ix5 added the improvement Not a new feature, but makes Isso more pleasant to use label Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client (Javascript) client code and CSS feature improvement Not a new feature, but makes Isso more pleasant to use
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant