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

Conversation

yamadapc
Copy link
Contributor

@yamadapc yamadapc commented Feb 5, 2025

Adds E2E playwright based tests. These allow us to test that built artifacts
work on browsers end-to-end.

Test Plan: Run yarn test:end-to-end

Created using spr 1.3.5
Created using spr 1.3.5
Created using spr 1.3.5
@yamadapc yamadapc requested a review from a team February 5, 2025 04:30
@yamadapc yamadapc enabled auto-merge (squash) February 5, 2025 04:30
@yamadapc yamadapc disabled auto-merge February 5, 2025 06:25
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.

Created using spr 1.3.5
Created using spr 1.3.5
Created using spr 1.3.5
Created using spr 1.3.5
Created using spr 1.3.5
Created using spr 1.3.5
@yamadapc yamadapc merged commit a442650 into main Feb 5, 2025
18 checks passed
@yamadapc yamadapc deleted the spr/yamadapc/add-playwright-end-to-end-tests branch February 5, 2025 23:24
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we start writing tests in TypeScript?

The Babel register function already supports TypeScript and Nodejs now supports TS natively without flags (only caveat is Nodejs TS support requires file extensions to be specified in the import)

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 suppose we could try to do that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants