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

Deps/node engines <16 #94

Merged
merged 3 commits into from Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
63 changes: 4 additions & 59 deletions .github/workflows/build-and-test.yml
Expand Up @@ -7,67 +7,12 @@ on:

jobs:

build-and-test-osx:
runs-on: macos-latest
build-and-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
fail-fast: false

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: yarn install
shell: bash
- run: yarn run dist:ci
shell: bash
- run: yarn link
shell: bash
- run: yarn run example:link
shell: bash
- run: yarn run example:install
shell: bash
- run: yarn run example:test:unit
shell: bash
- run: yarn run example:test:cy:run
shell: bash

build-and-test-ubuntu:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
fail-fast: false

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: yarn install
shell: bash
- run: yarn run dist:ci
shell: bash
- run: yarn link
shell: bash
- run: yarn run example:link
shell: bash
- run: yarn run example:install
shell: bash
- run: yarn run example:test:unit
shell: bash
- run: yarn run example:test:cy:run
shell: bash

build-and-test-windows:
runs-on: windows-latest
strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
os: [macos-latest, ubuntu-latest, windows-latest]
node-version: [16.x, 18.x, 19.x, 20.x]
fail-fast: false

steps:
Expand Down
25 changes: 17 additions & 8 deletions examples/react/src/api.js
Expand Up @@ -36,14 +36,23 @@ export class API {
}

async getProduct(id, params) {
return axios.get(this.withPath("/product/" + id), {
params,
headers: {
"Authorization": this.generateAuthToken()
}
})
.then(r => r.data);
}
try {
return await axios
.get(this.withPath('/product/' + id), {
params,
headers: {
Authorization: this.generateAuthToken()
}
})
.then((r) => r.data);
} catch (error) {
if (error.errors && error.errors.length > 0) {
return Promise.reject(new Error(error.errors));
} else {
return Promise.reject(new Error(error));
}
}
}

async postProduct(id, productData) {
return await axios.post(this.withPath("/product/" + id), productData, {
Expand Down
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -22,6 +22,9 @@
"peerDependencies": {
"msw": ">=0.35.0"
},
"engines": {
"node": ">=16"
},
"scripts": {
"build": "tsc",
"watch": "tsc --watch",
Expand All @@ -46,7 +49,7 @@
"@types/jest": "27.4.1",
"@typescript-eslint/eslint-plugin": "5.56.0",
"@typescript-eslint/parser": "5.59.5",
"axios": "0.26.0",
"axios": "0.26.1",
"babel-jest": "27.5.1",
"eslint": "8.10.0",
"jest": "27.5.1",
Expand Down
2 changes: 1 addition & 1 deletion src/pactFromMswServer.msw.spec.ts
Expand Up @@ -115,7 +115,7 @@ describe("API - With MSW mock generating a pact", () => {

test("unhandled route", async () => {
await expect(API.getProduct("11")).rejects.toThrow(
/^connect ECONNREFUSED (127.0.0.1|::1):8081$/
/^Error: connect ECONNREFUSED (127.0.0.1|::1):8081.*$/

Choose a reason for hiding this comment

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

Can we improve this error message more?

Copy link
Member Author

Choose a reason for hiding this comment

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

it’s just a generic error thrown from axios, ( in test code ), rather than users code. msw already logs out to the console that the request was unhandled

);
});

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -1870,10 +1870,10 @@ axios@*:
follow-redirects "^1.14.9"
form-data "^4.0.0"

axios@0.26.0:
version "0.26.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.26.0.tgz#9a318f1c69ec108f8cd5f3c3d390366635e13928"
integrity sha512-lKoGLMYtHvFrPVt3r+RBMp9nh34N0M8zEfCWqdWZx6phynIEhQqAdydpyBAAG211zlhX9Rgu08cOamy6XjE5Og==
axios@0.26.1:
version "0.26.1"
resolved "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz#1ede41c51fcf51bbbd6fd43669caaa4f0495aaa9"
integrity sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==
dependencies:
follow-redirects "^1.14.8"

Expand Down