diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 071978a776c7..ef450b50bf40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -417,7 +417,7 @@ jobs: if: needs.job_get_metadata.outputs.changed_any_code == 'true' strategy: matrix: - node: [ '18.12.1' ] + node: [ '18.12.1', '20.11.1' ] name: Unit tests (Node ${{ matrix.node }}) steps: - uses: actions/checkout@v4 @@ -455,7 +455,7 @@ jobs: if: needs.job_get_metadata.outputs.changed_core == 'true' strategy: matrix: - node: [ '18.12.1' ] + node: [ '18.12.1', '20.11.1' ] env: - DB: mysql8 NODE_ENV: testing-mysql diff --git a/ghost/admin/package.json b/ghost/admin/package.json index a42fa0d49b82..7c66f4e95eed 100644 --- a/ghost/admin/package.json +++ b/ghost/admin/package.json @@ -26,7 +26,7 @@ "lint": "yarn lint:js && yarn lint:hbs" }, "engines": { - "node": "^18.12.1" + "node": "^18.12.1 || ^20.11.1" }, "devDependencies": { "@babel/eslint-parser": "7.23.3", diff --git a/ghost/core/package.json b/ghost/core/package.json index 73b5de5ddf38..9bf4a2a742c7 100644 --- a/ghost/core/package.json +++ b/ghost/core/package.json @@ -53,8 +53,8 @@ "prepack": "node monobundle.js" }, "engines": { - "node": "^18.12.1", - "cli": "^1.25.0" + "node": "^18.12.1 || ^20.11.1", + "cli": "^1.26.0" }, "dependencies": { "@extractus/oembed-extractor": "3.2.1", diff --git a/ghost/core/test/unit/server/services/custom-redirects/api.test.js b/ghost/core/test/unit/server/services/custom-redirects/api.test.js index 66754f3c82fb..d7836996cf5e 100644 --- a/ghost/core/test/unit/server/services/custom-redirects/api.test.js +++ b/ghost/core/test/unit/server/services/custom-redirects/api.test.js @@ -95,15 +95,29 @@ describe('UNIT: redirects CustomRedirectsAPI class', function () { describe('setFromFilePath', function () { it('throws a syntax error when setting invalid JSON redirects file', async function () { + const invalidJSON = '{invalid json'; const invalidFilePath = path.join(__dirname, '/invalid/redirects/path.json'); - fs.readFile.withArgs(invalidFilePath, 'utf-8').resolves('{invalid json'); + fs.readFile.withArgs(invalidFilePath, 'utf-8').resolves(invalidJSON); + + let expectedErrorMessage; + + try { + JSON.parse(invalidJSON); + } catch (err) { + expectedErrorMessage = err.message; + } + + if (!expectedErrorMessage) { + // This should never happen because the JSON is invalid + should.fail('expectedErrorMessage is not set'); + } try { await customRedirectsAPI.setFromFilePath(invalidFilePath, '.json'); should.fail('setFromFilePath did not throw'); } catch (err) { should.exist(err); - err.message.should.eql('Could not parse JSON: Unexpected token i in JSON at position 1.'); + err.message.should.eql(`Could not parse JSON: ${expectedErrorMessage}.`); } });