From 177c4a7b17e713eae7d7e96d6e402878c73db367 Mon Sep 17 00:00:00 2001 From: JohnAlbin Date: Mon, 15 Apr 2024 20:29:05 +0800 Subject: [PATCH] testing code coverage --- .github/workflows/next-drupal.yml | 4 +++- packages/next-drupal/jest.config.cjs | 4 +++- packages/next-drupal/src/next-drupal.ts | 4 +++- packages/next-drupal/tests/NextDrupalBase/constructor.test.ts | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/next-drupal.yml b/.github/workflows/next-drupal.yml index c937f531..682b61a9 100644 --- a/.github/workflows/next-drupal.yml +++ b/.github/workflows/next-drupal.yml @@ -17,7 +17,9 @@ jobs: - name: Install packages run: yarn - name: Run tests - run: yarn test + run: | + yarn jest --clearCache + yarn test env: DRUPAL_BASE_URL: ${{ secrets.DRUPAL_BASE_URL }} DRUPAL_USERNAME: ${{ secrets.DRUPAL_USERNAME }} diff --git a/packages/next-drupal/jest.config.cjs b/packages/next-drupal/jest.config.cjs index 457ff9b9..66c4a36d 100644 --- a/packages/next-drupal/jest.config.cjs +++ b/packages/next-drupal/jest.config.cjs @@ -1,6 +1,7 @@ /** @type {import('ts-jest').JestConfigWithTsJest} */ module.exports = { - preset: "ts-jest", + preset: "ts-jest/presets/default-esm", + extensionsToTreatAsEsm: [".ts"], testEnvironment: "node", setupFiles: ["dotenv/config"], setupFilesAfterEnv: ["/jest.setup.ts"], @@ -10,6 +11,7 @@ module.exports = { "ts-jest", { isolatedModules: true, + useESM: true, }, ], }, diff --git a/packages/next-drupal/src/next-drupal.ts b/packages/next-drupal/src/next-drupal.ts index 19db4fd1..392790b1 100644 --- a/packages/next-drupal/src/next-drupal.ts +++ b/packages/next-drupal/src/next-drupal.ts @@ -778,7 +778,9 @@ export class NextDrupal extends NextDrupalBase { } deserialize(body, options?) { - if (!body) return null + if (!body) { + return null + } return this.deserializer(body, options) } diff --git a/packages/next-drupal/tests/NextDrupalBase/constructor.test.ts b/packages/next-drupal/tests/NextDrupalBase/constructor.test.ts index cd5a2c64..7c33bc80 100644 --- a/packages/next-drupal/tests/NextDrupalBase/constructor.test.ts +++ b/packages/next-drupal/tests/NextDrupalBase/constructor.test.ts @@ -20,7 +20,7 @@ describe("baseUrl parameter", () => { process.env = env }) - test("throws error given an invalid baseUrl", () => { + test("throws error given an invalid baseUrl", async () => { expect( () => // @ts-expect-error