chore: Fix test with node 18/20 error message (#323)

* Fix test with node 18/20 error message

* Run tests on node 18 and 20

* Enhance description

* Fix type and obj property

---------

Co-authored-by: Anatoly Laskaris <github_me@nahsi.dev>
This commit is contained in:
Akim 2023-08-09 20:04:22 +07:00 committed by GitHub
parent c99a509c87
commit 2d2f5591cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -38,7 +38,7 @@ jobs:
matrix:
node-version:
- 18.x
# - 20.x
- 20.x
steps:
- name: Import secrets

View File

@ -129,6 +129,12 @@ describe('Tests for default handler', () => {
// act
const fn = builtInServices[req.serviceId][req.fnName];
const res = await fn(req);
// Our test cases above depend on node error message. In node 20 error message for JSON.parse has changed.
// Simple and fast solution for this specific case is to unify both variations into node 18 version error format.
if (res.result === 'Unexpected token \'i\', "incorrect" is not valid JSON') {
res.result = 'Unexpected token i in JSON at position 0';
}
// assert
expect(res).toMatchObject({