Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Update snapshots and workflows for Node 20 #1021

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/imperative.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [16.x, 18.x]
node-version: [18.x, 20.x]
os: [windows-latest, ubuntu-latest, macos-latest]

env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ describe("cmd-cli respond with-data-object", () => {
TEST_ENVIRONMENT.workingDir);
expect(response.status).toBe(1);
expect(response.stdout.toString()).toBe("");
expect(response.stderr.toString()).toMatchSnapshot();
const regex = /(Unexpected token i in JSON at position 0)|(Unexpected token 'i', "invalid json!" is not valid JSON)/;
expect(response.stderr.toString()).toMatch(regex);
});

it("should allow us to formulate a response object with a data object and produce JSON", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe("cmd-cli respond with-syntax-errors", () => {
TEST_ENVIRONMENT.workingDir);
expect(response.stdout.toString()).toBe("");
expect(response.status).toBe(1);
expect(response.stderr.toString()).toMatchSnapshot();
const regex = /(Unexpected token d in JSON at position 1)|(Expected property name or '}' in JSON at position 1)/;
expect(response.stderr.toString()).toMatch(regex);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,6 @@ Use \\"cmd-cli respond with-data-object --help\\" to view command description, u
"
`;

exports[`cmd-cli respond with-data-object should display a syntax error if the JSON object passed is not valid 1`] = `
"
Syntax Error:
Invalid JSON string supplied for the following option:
--data-object

You specified:
invalid json!

JSON parsing failed with the following error:
Unexpected token i in JSON at position 0

Use \\"cmd-cli respond with-data-object --help\\" to view command description, usage, and options.
"
`;

exports[`cmd-cli respond with-data-object should display the help 1`] = `
"
COMMAND NAME
Expand Down

This file was deleted.

11 changes: 9 additions & 2 deletions __tests__/config/jest.preset.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@
}
},
"moduleFileExtensions": ["ts","js"],
"testResultsProcessor": "jest-stare",
"testEnvironment": "node",
"transform": {
".(ts)": "ts-jest"
}
},
"transformIgnorePatterns": ["^.+\\.js$", "^.+\\.json$"],
"reporters": [
["github-actions", {"silent": false}],
"default",
"jest-junit"
],
"globalSetup": "./__tests__/config/setup.js",
"globalTeardown": "./__tests__/config/teardown.js"
}
3 changes: 3 additions & 0 deletions __tests__/config/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = async function (globalConfig, projectConfig) {
require('events').EventEmitter.defaultMaxListeners = Infinity;
}
3 changes: 3 additions & 0 deletions __tests__/config/teardown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = async function (globalConfig, projectConfig) {
process.exitCode = 0; // Thanks Node 20
}
4 changes: 2 additions & 2 deletions packages/imperative/src/config/cmd/report-env/EnvItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ function formatLogLevelMsg(logTypeName: string) {
export const probTests: IProbTest[] = [
{
itemId: ItemId.NODEJS_VER,
probExpr: "semver.satisfies('{val}', '<14.x || 15.x || 17.x || >=19.x')",
probMsg: "Only Node.js versions 14, 16, and 18 are supported."
probExpr: "semver.satisfies('{val}', '<17.x || 19.x || >=21.x')",
Copy link
Member

Choose a reason for hiding this comment

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

you will find that this change has already been made in cli/add-imp-v2.

probMsg: "Only Node.js versions 18 and 20 are supported."
},
{
itemId: ItemId.NPM_VER,
Expand Down
6 changes: 4 additions & 2 deletions packages/rest/__tests__/client/AbstractRestClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ describe("AbstractRestClient tests", () => {
error = thrownError;
}
expect(error instanceof ImperativeError).toBe(true);
expect(error.message).toMatchSnapshot();
const regex = /(Unexpected end of JSON input)|(Expected ',' or '}' after property value in JSON at position 26)/;
expect(error.message).toMatch(regex);
});

it("should error when chunking JSON data that does not parse and allow post payload", async () => {
Expand Down Expand Up @@ -315,7 +316,8 @@ describe("AbstractRestClient tests", () => {
error = thrownError;
}
expect(error instanceof ImperativeError).toBe(true);
expect(error.message).toMatchSnapshot();
const regex = /(Unexpected end of JSON input)|(Expected ',' or '}' after property value in JSON at position 26)/;
expect(error.message).toMatch(regex);
expect(error.errorCode).toMatchSnapshot();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,7 @@ Object {
}
`;

exports[`AbstractRestClient tests should error when chunking JSON data that does not parse 1`] = `
"The get request appeared to succeed, but the response was not in the expected format:
Unexpected end of JSON input"
`;

exports[`AbstractRestClient tests should error when chunking JSON data that does not parse and allow post payload 1`] = `
"The post request appeared to succeed, but the response was not in the expected format:
Unexpected end of JSON input"
`;

exports[`AbstractRestClient tests should error when chunking JSON data that does not parse and allow post payload 2`] = `undefined`;
exports[`AbstractRestClient tests should error when chunking JSON data that does not parse and allow post payload 1`] = `undefined`;

exports[`AbstractRestClient tests should give an error message when error event is called 1`] = `"http(s) request error event called"`;

Expand Down
9 changes: 6 additions & 3 deletions packages/utilities/__tests__/JSONUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ describe("JSONUtils tests", () => {
} catch (thrownError) {
error = thrownError;
}
expect(error.message).toMatchSnapshot();
const regex = /(Unexpected token f in JSON at position 2)|(Expected property name or '}' in JSON at position 2)/;
expect(error.message).toMatch(regex);
});

it("should give a message for a failed JSON object with custom fail message", () => {
Expand All @@ -47,7 +48,8 @@ describe("JSONUtils tests", () => {
} catch (thrownError) {
error = thrownError;
}
expect(error.message).toMatchSnapshot();
const regex = /(Unexpected token f in JSON at position 2)|(Expected property name or '}' in JSON at position 2)/;
expect(error.message).toMatch(regex);
});

it("should give an error message for an undefined input", () => {
Expand All @@ -57,6 +59,7 @@ describe("JSONUtils tests", () => {
} catch (thrownError) {
error = thrownError;
}
expect(error.message).toMatchSnapshot();
const regex = /(Unexpected token u in JSON at position 0)|("undefined" is not valid JSON)/;
expect(error.message).toMatch(regex);
});
});
15 changes: 0 additions & 15 deletions packages/utilities/__tests__/__snapshots__/JSONUtils.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`JSONUtils tests should give a message for a failed JSON object 1`] = `
"Parse of { fail } failed:
Unexpected token f in JSON at position 2"
`;

exports[`JSONUtils tests should give a message for a failed JSON object with custom fail message 1`] = `
"test message:
Unexpected token f in JSON at position 2"
`;

exports[`JSONUtils tests should give an error message for an undefined input 1`] = `
"Parse of undefined failed:
Unexpected token u in JSON at position 0"
`;

exports[`JSONUtils tests should parse a JSON object 1`] = `
Object {
"name": "user",
Expand Down
3 changes: 2 additions & 1 deletion tsconfig-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@
],
"files": [
"./__types__/wontache.d.ts"
]
],
"allowJs": true
}
Loading