Skip to content

Commit

Permalink
Fixes testing different node versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ralexmatthews committed Jul 23, 2024
1 parent b6380cb commit adc91c5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@ jobs:
node-version: [12.x, 13.x, 14.x, 15.x, 16.x, 17.x, 18.x, 19.x, 20.x, 21.x, 22.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js 20.x To Build
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
node-version: 20.x
- run: make install
- run: make install-styleguide
- run: make build
- run: EASYPOST_TEST_API_KEY=123 EASYPOST_PROD_API_KEY=123 make test
- name: Use Node.js ${{ matrix.node-version }} to test importing and using
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: make test-import-and-use
lint:
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ scan:
test:
npm run test

## test actually importing and useing the built version
test-import-and-use:
npm run test-import-and-use

## update - Update dependencies (Unix only)
update: | update-examples-submodule
npm update
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"repl": "./repl.js --local ./dist/cjs",
"scan": "npx audit-ci -m --config ./audit-ci.jsonc",
"test": "cross-env NODE_ENV=test mocha",
"test-import-and-use": "node ./test-import.js",
"watch": "webpack --config webpack.config.babel.js --watch"
},
"dependencies": {
Expand Down
18 changes: 18 additions & 0 deletions test-import.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const EasyPostClient = require('./dist/cjs');

const client = new EasyPostClient.default('fake-api-key');

client.CarrierMetadata.retrieve()
.then(function () {
console.error("Request shouldn't have succeeded");
process.exit(1);
})
.catch(function (error) {
if (error.message.includes('This api key is no longer active')) {
console.log('seems to be working properly');
return;
}

console.error('wrong error received');
process.exit(1);
});

0 comments on commit adc91c5

Please sign in to comment.