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

Support for running in the browser #213

Open
2 tasks done
ruud opened this issue Jul 10, 2024 · 6 comments
Open
2 tasks done

Support for running in the browser #213

ruud opened this issue Jul 10, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@ruud
Copy link

ruud commented Jul 10, 2024

Checklist

Before making a feature request, I have:

Feature description

We would like to integrate pact-msw-adapter into the mock server of our test framework, which is open source and available at https://github.com/modernweb-dev/web/tree/master/packages/mocks. The mock server is based on MSW and the test-runner runs in the browser.

Use case

We would like to integrate the pact-msw-adapter to make it easy for our users to create Pact contracts. We expect that by integrating it into the mock server of the web test runner, the way of working of users, does not need to change, if they want to start creating contracts.

When adding the pact-msw-adapter we run into the following problems:

  • The adapter is only available as a commonjs package. This does not work in the browser.
  • When we change this (in a fork) we notice that it uses omit of lodash, which is also not available as an esmodule.
  • Last but not least, we see the use of the EventEmitter, which is Node specific and not available in the browser.

It would be helpful if your very useful adapter were available as an esmodule, so that we could properly integrate it into our web test-runner.

@ruud ruud added the enhancement New feature or request label Jul 10, 2024
@ruud
Copy link
Author

ruud commented Jul 15, 2024

MSW uses strict-event-emitter instead of the EventEmitter of Node. That could be a suggestion to stay compatable with MSW.

@ruud
Copy link
Author

ruud commented Jul 15, 2024

Also utils/utils.ts uses var path = require("path");.

It may be possible to separate the exports that target a node environment from the browser specific exports. Then they can be imported into the Web Test Runner separately.

For example, the creation of the contracts in the browser can be done by the web test-runner and the writing to files can be done by the node process.

@YOU54F
Copy link
Member

YOU54F commented Aug 12, 2024

Hey @ruud,

We would like to integrate pact-msw-adapter into the mock server of our test framework, which is open source and available at https://github.com/modernweb-dev/web/tree/master/packages/mocks. The mock server is based on MSW and the test-runner runs in the browser.

This sounds awesome, we'd love to see if we can support it.

If you can provide a pull request along with relevant tests, I'd definitely look to add that into the package.

with regards to lodash, I remember previously looking at removing it as a dep, there was a commit on the following branch but for whatever reason I never finished it off 😅

https://github.com/pactflow/pact-msw-adapter/tree/deps/rm/lodash

@rcollette
Copy link

To provide some context about how this would drive traffic to Pact/Pactflow @YOU54F - The Angular team is supposed to be replacing Karma with the Modern Web Test Runner in a future release.

@YOU54F
Copy link
Member

YOU54F commented Oct 10, 2024

interesting!

There is already an open issue for support for CDC on the project

modernweb-dev/web#2766

edit: ahh it was created by the OP

@ruud
Copy link
Author

ruud commented Oct 11, 2024

Modern web is setting standards for testing web components (using Lit) with the web test runner. For me Angular is out of scope.

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

No branches or pull requests

3 participants