From 0138499d5ffccd6fd7766a92302c48b875de1e0c Mon Sep 17 00:00:00 2001 From: Rifat Nabi Date: Mon, 8 Nov 2021 06:46:08 +1100 Subject: [PATCH] :wrench: Fix jest for esbuild --- jest.config.js | 12 ------- package-lock.json | 6 ++++ package.json | 6 +++- src/__tests__/__snapshots__/index.js.snap | 26 +++++++------- .../__tests__/__snapshots__/enum.js.snap | 36 +++++++++---------- .../__tests__/__snapshots__/required.js.snap | 8 ++--- 6 files changed, 46 insertions(+), 48 deletions(-) delete mode 100644 jest.config.js diff --git a/jest.config.js b/jest.config.js deleted file mode 100644 index 860366d8..00000000 --- a/jest.config.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = async () => { - return { - transform: { - '^.+\\.jsx?$': [ - 'esbuild-jest-transform', - { - target: 'es2015', - }, - ], - }, - }; -}; diff --git a/package-lock.json b/package-lock.json index 9d989959..c5721930 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3576,6 +3576,12 @@ "dev": true, "optional": true }, + "esbuild-jest-transform": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/esbuild-jest-transform/-/esbuild-jest-transform-1.1.0.tgz", + "integrity": "sha512-RHbXmpJsXiYm/5OGggqCfb3di0Dt1j8V39WNmYpMUB7VZOTTGOzvavfgIDEW2pvF9ieJHsOzwFaJmTOTZ/otkw==", + "dev": true + }, "esbuild-linux-32": { "version": "0.13.12", "resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.13.12.tgz", diff --git a/package.json b/package.json index a3d9accc..afcf6d66 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "@changesets/cli": "^2.17.0", "ajv": "^8.6.3", "esbuild": "^0.13.12", + "esbuild-jest-transform": "^1.1.0", "eslint": "^8.2.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-jest": "^25.2.3", @@ -67,6 +68,9 @@ "jest": { "testMatch": [ "/src/**/__tests__/**/*.js" - ] + ], + "transform": { + "^.+\\.js$": ["esbuild-jest-transform"] + } } } diff --git a/src/__tests__/__snapshots__/index.js.snap b/src/__tests__/__snapshots__/index.js.snap index 3c2162e6..7ad4364b 100644 --- a/src/__tests__/__snapshots__/index.js.snap +++ b/src/__tests__/__snapshots__/index.js.snap @@ -4,23 +4,23 @@ exports[`Main should output error with codeframe 1`] = ` "ENUM must be equal to one of the allowed values (paragraph, codeBlock, blockquote) -  2 |  \\"type\\": \\"doc\\", -  3 |  \\"version\\": 1, -> 4 |  \\"content\\": [{ \\"type\\": \\"paragarph\\" }] -  |  ^^^^^^^^^^^ 👈🏽 Did you mean paragraph here? -  5 | } -  6 | " +  2 | \\"type\\": \\"doc\\", +  3 | \\"version\\": 1, +> 4 | \\"content\\": [{ \\"type\\": \\"paragarph\\" }] +  | ^^^^^^^^^^^ 👈🏽 Did you mean paragraph here? +  5 | } +  6 |" `; exports[`Main should output error with reconstructed codeframe 1`] = ` "ENUM must be equal to one of the allowed values (paragraph, codeBlock, blockquote) -  4 |  \\"content\\": [ -  5 |  { -> 6 |  \\"type\\": \\"paragarph\\" -  |  ^^^^^^^^^^^ 👈🏽 Did you mean paragraph here? -  7 |  } -  8 |  ] -  9 | }" +  4 | \\"content\\": [ +  5 | { +> 6 | \\"type\\": \\"paragarph\\" +  | ^^^^^^^^^^^ 👈🏽 Did you mean paragraph here? +  7 | } +  8 | ] +  9 | }" `; diff --git a/src/validation-errors/__tests__/__snapshots__/enum.js.snap b/src/validation-errors/__tests__/__snapshots__/enum.js.snap index 860494b4..19f3e3dc 100644 --- a/src/validation-errors/__tests__/__snapshots__/enum.js.snap +++ b/src/validation-errors/__tests__/__snapshots__/enum.js.snap @@ -5,8 +5,8 @@ Array [ "ENUM should be equal to one of the allowed values", "(foo, bar) ", - "> 1 | \\"baz\\" -  | ^^^^^ 👈🏽 Did you mean bar here?", + "> 1 | \\"baz\\" +  | ^^^^^ 👈🏽 Did you mean bar here?", ] `; @@ -15,8 +15,8 @@ Array [ "ENUM should be equal to one of the allowed values", "(foo, bar) ", - "> 1 | \\"baz\\" -  | ^^^^^ 👈🏽 Did you mean bar here?", + "> 1 | \\"baz\\" +  | ^^^^^ 👈🏽 Did you mean bar here?", ] `; @@ -25,8 +25,8 @@ Array [ "ENUM should be equal to one of the allowed values", "(one, two) ", - "> 1 | \\"baz\\" -  | ^^^^^ 👈🏽 Unexpected value, should be equal to one of the allowed values", + "> 1 | \\"baz\\" +  | ^^^^^ 👈🏽 Unexpected value, should be equal to one of the allowed values", ] `; @@ -35,10 +35,10 @@ Array [ "ENUM should be equal to one of the allowed values", "(foo, bar) ", - "  1 | { -> 2 |  \\"id\\": \\"baz\\" -  |  ^^^^^ 👈🏽 Did you mean bar here? -  3 | }", + "  1 | { +> 2 | \\"id\\": \\"baz\\" +  | ^^^^^ 👈🏽 Did you mean bar here? +  3 | }", ] `; @@ -47,10 +47,10 @@ Array [ "ENUM should be equal to one of the allowed values", "(foo, bar) ", - "  1 | { -> 2 |  \\"id\\": \\"baz\\" -  |  ^^^^^ 👈🏽 Did you mean bar here? -  3 | }", + "  1 | { +> 2 | \\"id\\": \\"baz\\" +  | ^^^^^ 👈🏽 Did you mean bar here? +  3 | }", ] `; @@ -59,9 +59,9 @@ Array [ "ENUM should be equal to one of the allowed values", "(one, two) ", - "  1 | { -> 2 |  \\"id\\": \\"baz\\" -  |  ^^^^^ 👈🏽 Unexpected value, should be equal to one of the allowed values -  3 | }", + "  1 | { +> 2 | \\"id\\": \\"baz\\" +  | ^^^^^ 👈🏽 Unexpected value, should be equal to one of the allowed values +  3 | }", ] `; diff --git a/src/validation-errors/__tests__/__snapshots__/required.js.snap b/src/validation-errors/__tests__/__snapshots__/required.js.snap index 756e4664..3e174c65 100644 --- a/src/validation-errors/__tests__/__snapshots__/required.js.snap +++ b/src/validation-errors/__tests__/__snapshots__/required.js.snap @@ -4,9 +4,9 @@ exports[`Required prints correctly for missing required prop 1`] = ` Array [ "REQUIRED should have required property 'id' ", - "  1 | { -> 2 |  \\"nested\\": {} -  |  ^ ☹️ id is missing here! -  3 | }", + "  1 | { +> 2 | \\"nested\\": {} +  | ^ ☹️ id is missing here! +  3 | }", ] `;