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 playwright end-to-end tests #322

Merged
merged 11 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,33 @@ jobs:
env:
ATLASPACK_V3: ${{ matrix.version == 'v3' && 'true' || 'false' }}

end_to_end_tests:
name: E2E tests
timeout-minutes: 35
strategy:
matrix:
node: [20]
os: [ubuntu-latest]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the idea is to test the built artifacts, should we test more targets?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the artefacts would hopefully be guaranteed to be the same across environments (and that other tests would aim to guarantee that). So then it'd be a waste to run playwright tests on all OSs/versions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends on what you mean by artifacts in this case, but the Rust artifacts would be per platform. They get copied per arch / os in the release workflow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. Let me clarify;

  • The intention of this PR is to load javascript, CSS and HTML files onto a web browser to test certain E2E functionality that is currently not covered by Node.js test suites (which load bundles into the Node.js VM module)
  • For example: certain async loading functionality, all of HTML transform/bundle/packaging functionality, other browser specific functionality

So by 'built artefact' I mean: HTML, CSS, JavaScript, Images, built by atlaspack itself.

It is true that atlaspack itself might be running on different versions of Node.js or running binaries compiled for different operating systems or architectures. Those compiled binaries could also be called 'build artefacts'.

I do not think it's necessary to test the 'bundler artefacts' (HTML/CSS/JavaScript) for each compiled binary/node.js version target (Linux/v22/macOS/v18), because unless there is a platform specific bug or a compiler bug the 'bundler artefacts' (HTML/CSS/JavaScript) should be the same across platforms.

Since we already have "integration tests" running per platform and version, I thought those tests can be thought to/aim to guarantee that the output (the 'bundler artefacts' HTML/CSS/JavaScript) is correct and the same regardless of the environment (Linux/v22/macOS/v18).

Browser based E2E tests would guarantee that provided the bundler runs, its outputs also work on a web browser.

Because these are browser based tests, which ought to be slow and have certain drawbacks, I thought it'd be enough to run them on their own job on linux only.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may add more browsers / OSs too, but I'd want to avoid adding 4 new jobs for this. I can instead just copy this into the integration test suite if that seems better, I'll just need to provision playwright onto the integration test jobs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the terminology is ambiguous which is why I was confused. What you've said makes sense, all good.

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
cache: yarn
node-version: ${{ matrix.node }}
- uses: ./.github/actions/rust-toolchain
- uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ matrix.os }}
- name: Bump max inotify watches (Linux only)
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p;
if: ${{ runner.os == 'Linux' }}
- run: yarn --frozen-lockfile
- run: yarn build-native-release
- run: yarn build
- run: yarn playwright install
- run: yarn test:end-to-end:ci

repl:
name: Deploy REPL
if: false # ${{ github.event_name == 'pull_request' }}
Expand Down
2 changes: 1 addition & 1 deletion .mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function isFileArg(file) {

const spec = args.some(isFileArg)
? args.filter(isFileArg)
: 'packages/*/!(integration-tests)/test/{*.{js,ts,cts,mts,cjs,mjs},**/*.{test,spec}.{js,ts,mts,cts,cjs,mjs}}';
: 'packages/*/!(integration-tests|end-to-end-tests)/test/{*.{js,ts,cts,mts,cjs,mjs},**/*.{test,spec}.{js,ts,mts,cts,cjs,mjs}}';

module.exports = {
spec,
Expand Down
Loading