From fefa3474a1b24e2861609350208291d4244212e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Wed, 24 Aug 2022 15:35:20 +0200 Subject: [PATCH] Remove line numbers in snapshot --- packages/babel-core/test/errors-stacks.js | 93 ++++++++++++----------- 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/packages/babel-core/test/errors-stacks.js b/packages/babel-core/test/errors-stacks.js index d639e0fe58fc..9face3ebb355 100644 --- a/packages/babel-core/test/errors-stacks.js +++ b/packages/babel-core/test/errors-stacks.js @@ -19,6 +19,9 @@ function expectError(run) { "\n ... internal jest frames ...", ); stack = replaceAll(stack, process.cwd(), ""); + // Replace line/column numbers, since they are affected by how + // the code is compiled. + stack = stack.replace(/:\d+:\d+\)$/gm, ":_:_)"); return expect(stack); } throw new Error("It should have thrown an error."); @@ -35,8 +38,8 @@ describe("@babel/core errors", function () { }); }).toMatchInlineSnapshot(` "Error: Error inside config! - at myConfig (/packages/babel-core/test/fixtures/errors/error-config-function/babel.config.js:2:9) - at Module.parseSync (/packages/babel-core/lib/parse.js:58:72) + at myConfig (/packages/babel-core/test/fixtures/errors/error-config-function/babel.config.js:_:_) + at Module.parseSync (/packages/babel-core/lib/parse.js:_:_) ... frames from this test file ... ... internal jest frames ..." `); @@ -49,10 +52,10 @@ describe("@babel/core errors", function () { }); }).toMatchInlineSnapshot(` "Error: Error inside config! - at f (/packages/babel-core/test/fixtures/errors/error-config-function-more-frames/babel.config.js:6:9) - at g (/packages/babel-core/test/fixtures/errors/error-config-function-more-frames/babel.config.js:10:3) - at myConfig (/packages/babel-core/test/fixtures/errors/error-config-function-more-frames/babel.config.js:2:3) - at Module.parseSync (/packages/babel-core/lib/parse.js:58:72) + at f (/packages/babel-core/test/fixtures/errors/error-config-function-more-frames/babel.config.js:_:_) + at g (/packages/babel-core/test/fixtures/errors/error-config-function-more-frames/babel.config.js:_:_) + at myConfig (/packages/babel-core/test/fixtures/errors/error-config-function-more-frames/babel.config.js:_:_) + at Module.parseSync (/packages/babel-core/lib/parse.js:_:_) ... frames from this test file ... ... internal jest frames ..." `); @@ -65,14 +68,14 @@ describe("@babel/core errors", function () { }); }).toMatchInlineSnapshot(` "Error: Error inside config! - at Object. (/packages/babel-core/test/fixtures/errors/error-config-file/babel.config.js:4:7) - at Module._compile (node:internal/modules/cjs/loader:1120:14) - at Module._extensions..js (node:internal/modules/cjs/loader:1174:10) - at Module.load (node:internal/modules/cjs/loader:998:32) - at Module._load (node:internal/modules/cjs/loader:839:12) - at Module.require (node:internal/modules/cjs/loader:1022:19) - at require (node:internal/modules/cjs/helpers:102:18) - at Module.parseSync (/packages/babel-core/lib/parse.js:58:72) + at Object. (/packages/babel-core/test/fixtures/errors/error-config-file/babel.config.js:_:_) + at Module._compile (node:internal/modules/cjs/loader:_:_) + at Module._extensions..js (node:internal/modules/cjs/loader:_:_) + at Module.load (node:internal/modules/cjs/loader:_:_) + at Module._load (node:internal/modules/cjs/loader:_:_) + at Module.require (node:internal/modules/cjs/loader:_:_) + at require (node:internal/modules/cjs/helpers:_:_) + at Module.parseSync (/packages/babel-core/lib/parse.js:_:_) ... frames from this test file ..." `); }); @@ -84,16 +87,16 @@ describe("@babel/core errors", function () { }); }).toMatchInlineSnapshot(` "Error: Error inside config! - at f (/packages/babel-core/test/fixtures/errors/error-config-file-more-frames/babel.config.js:7:9) - at g (/packages/babel-core/test/fixtures/errors/error-config-file-more-frames/babel.config.js:11:3) - at Object. (/packages/babel-core/test/fixtures/errors/error-config-file-more-frames/babel.config.js:1:1) - at Module._compile (node:internal/modules/cjs/loader:1120:14) - at Module._extensions..js (node:internal/modules/cjs/loader:1174:10) - at Module.load (node:internal/modules/cjs/loader:998:32) - at Module._load (node:internal/modules/cjs/loader:839:12) - at Module.require (node:internal/modules/cjs/loader:1022:19) - at require (node:internal/modules/cjs/helpers:102:18) - at Module.parseSync (/packages/babel-core/lib/parse.js:58:72)" + at f (/packages/babel-core/test/fixtures/errors/error-config-file-more-frames/babel.config.js:_:_) + at g (/packages/babel-core/test/fixtures/errors/error-config-file-more-frames/babel.config.js:_:_) + at Object. (/packages/babel-core/test/fixtures/errors/error-config-file-more-frames/babel.config.js:_:_) + at Module._compile (node:internal/modules/cjs/loader:_:_) + at Module._extensions..js (node:internal/modules/cjs/loader:_:_) + at Module.load (node:internal/modules/cjs/loader:_:_) + at Module._load (node:internal/modules/cjs/loader:_:_) + at Module.require (node:internal/modules/cjs/loader:_:_) + at require (node:internal/modules/cjs/helpers:_:_) + at Module.parseSync (/packages/babel-core/lib/parse.js:_:_)" `); }); @@ -107,16 +110,16 @@ describe("@babel/core errors", function () { }); }).toMatchInlineSnapshot(` "Error: Error inside config! - at f (/packages/babel-core/test/fixtures/errors/error-config-file-more-frames/babel.config.js:7:9) - at g (/packages/babel-core/test/fixtures/errors/error-config-file-more-frames/babel.config.js:11:3) - at Object. (/packages/babel-core/test/fixtures/errors/error-config-file-more-frames/babel.config.js:1:1) - at Module._compile (node:internal/modules/cjs/loader:1120:14) - at Module._extensions..js (node:internal/modules/cjs/loader:1174:10) - at Module.load (node:internal/modules/cjs/loader:998:32) - at Module._load (node:internal/modules/cjs/loader:839:12) - at Module.require (node:internal/modules/cjs/loader:1022:19) - at require (node:internal/modules/cjs/helpers:102:18) - at Module.parseSync (/packages/babel-core/lib/parse.js:58:72) + at f (/packages/babel-core/test/fixtures/errors/error-config-file-more-frames/babel.config.js:_:_) + at g (/packages/babel-core/test/fixtures/errors/error-config-file-more-frames/babel.config.js:_:_) + at Object. (/packages/babel-core/test/fixtures/errors/error-config-file-more-frames/babel.config.js:_:_) + at Module._compile (node:internal/modules/cjs/loader:_:_) + at Module._extensions..js (node:internal/modules/cjs/loader:_:_) + at Module.load (node:internal/modules/cjs/loader:_:_) + at Module._load (node:internal/modules/cjs/loader:_:_) + at Module.require (node:internal/modules/cjs/loader:_:_) + at require (node:internal/modules/cjs/helpers:_:_) + at Module.parseSync (/packages/babel-core/lib/parse.js:_:_) ... frames from this test file ... ... internal jest frames ..." `); @@ -133,7 +136,7 @@ describe("@babel/core errors", function () { }).toMatchInlineSnapshot(` "Error: Error while parsing config - JSON5: invalid character '}' at 3:1 at /packages/babel-core/test/fixtures/errors/invalid-json/babel.config.json - at Module.parseSync (/packages/babel-core/lib/parse.js:58:72) + at Module.parseSync (/packages/babel-core/lib/parse.js:_:_) ... frames from this test file ... ... internal jest frames ..." `); @@ -147,7 +150,7 @@ describe("@babel/core errors", function () { }).toMatchInlineSnapshot(` "Error: Configuration contains string/RegExp pattern, but no filename was passed to Babel at /packages/babel-core/test/fixtures/errors/use-exclude/babel.config.js - at Module.parseSync (/packages/babel-core/lib/parse.js:58:72) + at Module.parseSync (/packages/babel-core/lib/parse.js:_:_) ... frames from this test file ... ... internal jest frames ..." `); @@ -161,7 +164,7 @@ describe("@babel/core errors", function () { }); }).toMatchInlineSnapshot(` "Error: Configuration contains string/RegExp pattern, but no filename was passed to Babel - at Module.parseSync (/packages/babel-core/lib/parse.js:58:72) + at Module.parseSync (/packages/babel-core/lib/parse.js:_:_) ... frames from this test file ... ... internal jest frames ..." `); @@ -178,7 +181,7 @@ describe("@babel/core errors", function () { babel.transformSync(code, { filename: 'file.ts', presets: [/* your preset */] }); \`\`\` See https://babeljs.io/docs/en/options#filename for more information. - at Module.parseSync (/packages/babel-core/lib/parse.js:58:72) + at Module.parseSync (/packages/babel-core/lib/parse.js:_:_) ... frames from this test file ... ... internal jest frames ..." `); @@ -192,7 +195,7 @@ describe("@babel/core errors", function () { }).toMatchInlineSnapshot(` "Error: .sourceType must be \\"module\\", \\"script\\", \\"unambiguous\\", or undefined at /packages/babel-core/test/fixtures/errors/invalid-option/babel.config.json - at Module.parseSync (/packages/babel-core/lib/parse.js:58:72) + at Module.parseSync (/packages/babel-core/lib/parse.js:_:_) ... frames from this test file ... ... internal jest frames ..." `); @@ -206,7 +209,7 @@ describe("@babel/core errors", function () { }), ).toMatchInlineSnapshot(` "Error: .sourceType must be \\"module\\", \\"script\\", \\"unambiguous\\", or undefined - at Module.parseSync (/packages/babel-core/lib/parse.js:58:72) + at Module.parseSync (/packages/babel-core/lib/parse.js:_:_) ... frames from this test file ... ... internal jest frames ..." `); @@ -228,15 +231,15 @@ describe("@babel/core errors", function () { }).toMatchInlineSnapshot(` "Error: Internal error! This is a fake bug :) ... frames from this test file ... - at loadOneConfig (/packages/babel-core/lib/config/files/configuration.js:148:47) + at loadOneConfig (/packages/babel-core/lib/config/files/configuration.js:_:_) at loadOneConfig.next () - at buildRootChain (/packages/babel-core/lib/config/config-chain.js:86:51) + at buildRootChain (/packages/babel-core/lib/config/config-chain.js:_:_) at buildRootChain.next () - at loadPrivatePartialConfig (/packages/babel-core/lib/config/partial.js:103:62) + at loadPrivatePartialConfig (/packages/babel-core/lib/config/partial.js:_:_) at loadPrivatePartialConfig.next () - at loadFullConfig (/packages/babel-core/lib/config/full.js:57:46) + at loadFullConfig (/packages/babel-core/lib/config/full.js:_:_) at loadFullConfig.next () - at parse (/packages/babel-core/lib/parse.js:29:45)" + at parse (/packages/babel-core/lib/parse.js:_:_)" `); }); });