Skip to content

Commit

Permalink
Merge #1916
Browse files Browse the repository at this point in the history
1916: Fix msw r=ZauberNerd a=ZauberNerd

<details>
<summary>Bors merge bot cheat sheet</summary>

We are using [bors-ng](https://github.com/bors-ng/bors-ng) to automate merging of our pull requests. The following table provides a summary of commands that are available to reviewers (members of this repository with push access) and delegates (in case of `bors delegate+` or `bors delegate=[list]`).

| Syntax | Description |
| --- | --- |
| bors merge | Run the test suite and push to master if it passes. Short for "reviewed: looks good." |
| bors merge- | Cancel an r+, r=, merge, or merge= |
| bors try | Run the test suite without pushing to master. |
| bors try- | Cancel a try |
| bors delegate+ | Allow the pull request author to merge their changes. |
| bors delegate=[list] | Allow the listed users to r+ this pull request's changes. |
| bors retry | Run the previous command a second time. |

This is a short collection of opinionated commands. For a full list of the commands read the [bors reference](https://bors.tech/documentation/).

</details>


Co-authored-by: ZauberNerd <[email protected]>
  • Loading branch information
bors[bot] and ZauberNerd authored Jul 13, 2021
2 parents 2ef4244 + 7b6b9c4 commit 7bb0628
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 17 deletions.
1 change: 1 addition & 0 deletions packages/msw/handlers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports.handlers = [];
10 changes: 3 additions & 7 deletions packages/msw/mixin.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,9 @@ class MswMixin extends Mixin {
const { setupWorker, graphql, rest } = await import('msw');
const worker = setupWorker();

try {
// eslint-disable-next-line node/no-unsupported-features/es-syntax, import/no-unresolved, node/no-missing-import
const { handlers } = await import('hops-msw/handlers');
handlers.forEach((handler) => worker.use(handler));
} catch {
// ignore if no handlers file has been provided
}
// eslint-disable-next-line node/no-unsupported-features/es-syntax, node/no-extraneous-import
const { handlers } = await import('hops-msw/handlers');
handlers.forEach((handler) => worker.use(handler));

const registerBrowserMock = (mock) => {
worker.use(createBrowserMock({ graphql, rest }, mock));
Expand Down
7 changes: 6 additions & 1 deletion packages/spec/integration/redux/__tests__/develop.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ describe('redux development server', () => {
let url;

beforeAll(async () => {
const { getUrl } = HopsCLI.start('--fast-dev');
const { getUrl } = HopsCLI.start(
{
PORT: '8950',
},
'--fast-dev'
);
url = await getUrl();
});

Expand Down
1 change: 1 addition & 0 deletions packages/spec/integration/redux/__tests__/mocked.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('development server with msw mocks', () => {
const { getUrl } = HopsCLI.start(
{
ENABLE_MSW: 'true',
PORT: '8949',
},
'--fast-dev'
);
Expand Down
16 changes: 9 additions & 7 deletions packages/spec/integration/redux/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ const reducers = {

const increment = () => ({ type: 'INCREMENT', payload: 1 });

const incrementFetch = () => (dispatch) => {
return fetch('http://localhost:8901/api')
.then((r) => r.json())
.then(({ value }) => {
dispatch({ type: 'INCREMENT', payload: value });
});
};
const incrementFetch =
() =>
(dispatch, _, { config }) => {
return fetch(`http://localhost:${config.port}/api`)
.then((r) => r.json())
.then(({ value }) => {
dispatch({ type: 'INCREMENT', payload: value });
});
};

const setParam = ({ param }) => ({ type: 'SET_VALUE', payload: param });

Expand Down
7 changes: 5 additions & 2 deletions packages/spec/integration/redux/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
},
"hops": {
"gracePeriod": 0,
"port": "8901",
"port": "[PORT]",
"mixins": [
"./"
]
],
"browserWhitelist": {
"port": true
}
},
"dependencies": {
"cross-fetch": "*",
Expand Down

0 comments on commit 7bb0628

Please sign in to comment.