From 0cf81e4ef4ed1d8a10821998dc3df4c16ec56185 Mon Sep 17 00:00:00 2001 From: David Anson Date: Tue, 18 Apr 2023 19:55:56 -0700 Subject: [PATCH] Add Node 20 to CI matrix, update test cases to handle new error strings in Node 20. --- .github/workflows/ci.yml | 2 +- test/markdownlint-test-config.js | 8 ++++---- test/markdownlint-test-custom-rules.js | 9 +++++++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 201f31db..e7363974 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: os: [macos-latest, ubuntu-latest, windows-latest] - node-version: [ 14, 16, 18 ] + node-version: [ 14, 16, 18, 20 ] steps: - uses: actions/checkout@v3 diff --git a/test/markdownlint-test-config.js b/test/markdownlint-test-config.js index 46f430d9..c052f21c 100644 --- a/test/markdownlint-test-config.js +++ b/test/markdownlint-test-config.js @@ -252,7 +252,7 @@ test("configBadHybrid", (t) => new Promise((resolve) => { t.true(err instanceof Error, "Error not instance of Error."); t.truthy(err.message.match( // eslint-disable-next-line max-len - /^Unable to parse '[^']*'; Parser \d+: Unexpected token \S+ in JSON at position \d+;/ + /^Unable to parse '[^']*'; Parser \d+: (Unexpected token|Expected property name)/ ), "Error message unexpected."); t.true(!result, "Got result for bad child JSON."); resolve(); @@ -333,7 +333,7 @@ test("configBadJsonSync", (t) => { { "message": // eslint-disable-next-line max-len - /Unable to parse '[^']*'; Parser \d+: Unexpected token \S+ in JSON at position \d+/ + /Unable to parse '[^']*'; Parser \d+: (Unexpected token|Expected property name)/ }, "Did not get correct exception for bad JSON." ); @@ -348,7 +348,7 @@ test("configBadChildJsonSync", (t) => { { "message": // eslint-disable-next-line max-len - /Unable to parse '[^']*'; Parser \d+: Unexpected token \S+ in JSON at position \d+/ + /Unable to parse '[^']*'; Parser \d+: (Unexpected token|Expected property name)/ }, "Did not get correct exception for bad child JSON." ); @@ -442,7 +442,7 @@ test("configBadHybridSync", (t) => { }, { // eslint-disable-next-line max-len - "message": /^Unable to parse '[^']*'; Parser \d+: Unexpected token \S+ in JSON at position \d+;/ + "message": /^Unable to parse '[^']*'; Parser \d+: (Unexpected token|Expected property name)/ }, "Did not get correct exception for bad content." ); diff --git a/test/markdownlint-test-custom-rules.js b/test/markdownlint-test-custom-rules.js index 5a3b084e..1f3c2e85 100644 --- a/test/markdownlint-test-custom-rules.js +++ b/test/markdownlint-test-custom-rules.js @@ -1158,7 +1158,7 @@ test("customRulesLintJavaScript", (t) => new Promise((resolve) => { })); test("customRulesValidateJson", (t) => new Promise((resolve) => { - t.plan(2); + t.plan(3); const options = { "customRules": customRules.validateJson, "files": "test/validate-json.md" @@ -1172,13 +1172,18 @@ test("customRulesValidateJson", (t) => new Promise((resolve) => { "ruleNames": [ "validate-json" ], "ruleDescription": "Rule that validates JSON code", "ruleInformation": null, - "errorDetail": "Unexpected end of JSON input", "errorContext": null, "errorRange": null, "fixInfo": null } ] }; + t.true( + actual && (actual["test/validate-json.md"][0].errorDetail.length > 0), + "Missing errorDetail" + ); + // @ts-ignore + delete actual["test/validate-json.md"][0].errorDetail; t.deepEqual(actual, expected, "Unexpected issues."); resolve(); });