Skip to content

Commit

Permalink
Remove line numbers in snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Aug 24, 2022
1 parent 53b7938 commit fefa347
Showing 1 changed file with 48 additions and 45 deletions.
93 changes: 48 additions & 45 deletions packages/babel-core/test/errors-stacks.js
Expand Up @@ -19,6 +19,9 @@ function expectError(run) {
"\n ... internal jest frames ...",
);
stack = replaceAll(stack, process.cwd(), "<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.");
Expand All @@ -35,8 +38,8 @@ describe("@babel/core errors", function () {
});
}).toMatchInlineSnapshot(`
"Error: Error inside config!
at myConfig (<CWD>/packages/babel-core/test/fixtures/errors/error-config-function/babel.config.js:2:9)
at Module.parseSync (<CWD>/packages/babel-core/lib/parse.js:58:72)
at myConfig (<CWD>/packages/babel-core/test/fixtures/errors/error-config-function/babel.config.js:_:_)
at Module.parseSync (<CWD>/packages/babel-core/lib/parse.js:_:_)
... frames from this test file ...
... internal jest frames ..."
`);
Expand All @@ -49,10 +52,10 @@ describe("@babel/core errors", function () {
});
}).toMatchInlineSnapshot(`
"Error: Error inside config!
at f (<CWD>/packages/babel-core/test/fixtures/errors/error-config-function-more-frames/babel.config.js:6:9)
at g (<CWD>/packages/babel-core/test/fixtures/errors/error-config-function-more-frames/babel.config.js:10:3)
at myConfig (<CWD>/packages/babel-core/test/fixtures/errors/error-config-function-more-frames/babel.config.js:2:3)
at Module.parseSync (<CWD>/packages/babel-core/lib/parse.js:58:72)
at f (<CWD>/packages/babel-core/test/fixtures/errors/error-config-function-more-frames/babel.config.js:_:_)
at g (<CWD>/packages/babel-core/test/fixtures/errors/error-config-function-more-frames/babel.config.js:_:_)
at myConfig (<CWD>/packages/babel-core/test/fixtures/errors/error-config-function-more-frames/babel.config.js:_:_)
at Module.parseSync (<CWD>/packages/babel-core/lib/parse.js:_:_)
... frames from this test file ...
... internal jest frames ..."
`);
Expand All @@ -65,14 +68,14 @@ describe("@babel/core errors", function () {
});
}).toMatchInlineSnapshot(`
"Error: Error inside config!
at Object.<anonymous> (<CWD>/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 (<CWD>/packages/babel-core/lib/parse.js:58:72)
at Object.<anonymous> (<CWD>/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 (<CWD>/packages/babel-core/lib/parse.js:_:_)
... frames from this test file ..."
`);
});
Expand All @@ -84,16 +87,16 @@ describe("@babel/core errors", function () {
});
}).toMatchInlineSnapshot(`
"Error: Error inside config!
at f (<CWD>/packages/babel-core/test/fixtures/errors/error-config-file-more-frames/babel.config.js:7:9)
at g (<CWD>/packages/babel-core/test/fixtures/errors/error-config-file-more-frames/babel.config.js:11:3)
at Object.<anonymous> (<CWD>/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 (<CWD>/packages/babel-core/lib/parse.js:58:72)"
at f (<CWD>/packages/babel-core/test/fixtures/errors/error-config-file-more-frames/babel.config.js:_:_)
at g (<CWD>/packages/babel-core/test/fixtures/errors/error-config-file-more-frames/babel.config.js:_:_)
at Object.<anonymous> (<CWD>/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 (<CWD>/packages/babel-core/lib/parse.js:_:_)"
`);
});

Expand All @@ -107,16 +110,16 @@ describe("@babel/core errors", function () {
});
}).toMatchInlineSnapshot(`
"Error: Error inside config!
at f (<CWD>/packages/babel-core/test/fixtures/errors/error-config-file-more-frames/babel.config.js:7:9)
at g (<CWD>/packages/babel-core/test/fixtures/errors/error-config-file-more-frames/babel.config.js:11:3)
at Object.<anonymous> (<CWD>/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 (<CWD>/packages/babel-core/lib/parse.js:58:72)
at f (<CWD>/packages/babel-core/test/fixtures/errors/error-config-file-more-frames/babel.config.js:_:_)
at g (<CWD>/packages/babel-core/test/fixtures/errors/error-config-file-more-frames/babel.config.js:_:_)
at Object.<anonymous> (<CWD>/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 (<CWD>/packages/babel-core/lib/parse.js:_:_)
... frames from this test file ...
... internal jest frames ..."
`);
Expand All @@ -133,7 +136,7 @@ describe("@babel/core errors", function () {
}).toMatchInlineSnapshot(`
"Error: Error while parsing config - JSON5: invalid character '}' at 3:1
at <CWD>/packages/babel-core/test/fixtures/errors/invalid-json/babel.config.json
at Module.parseSync (<CWD>/packages/babel-core/lib/parse.js:58:72)
at Module.parseSync (<CWD>/packages/babel-core/lib/parse.js:_:_)
... frames from this test file ...
... internal jest frames ..."
`);
Expand All @@ -147,7 +150,7 @@ describe("@babel/core errors", function () {
}).toMatchInlineSnapshot(`
"Error: Configuration contains string/RegExp pattern, but no filename was passed to Babel
at <CWD>/packages/babel-core/test/fixtures/errors/use-exclude/babel.config.js
at Module.parseSync (<CWD>/packages/babel-core/lib/parse.js:58:72)
at Module.parseSync (<CWD>/packages/babel-core/lib/parse.js:_:_)
... frames from this test file ...
... internal jest frames ..."
`);
Expand All @@ -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 (<CWD>/packages/babel-core/lib/parse.js:58:72)
at Module.parseSync (<CWD>/packages/babel-core/lib/parse.js:_:_)
... frames from this test file ...
... internal jest frames ..."
`);
Expand All @@ -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 (<CWD>/packages/babel-core/lib/parse.js:58:72)
at Module.parseSync (<CWD>/packages/babel-core/lib/parse.js:_:_)
... frames from this test file ...
... internal jest frames ..."
`);
Expand All @@ -192,7 +195,7 @@ describe("@babel/core errors", function () {
}).toMatchInlineSnapshot(`
"Error: .sourceType must be \\"module\\", \\"script\\", \\"unambiguous\\", or undefined
at <CWD>/packages/babel-core/test/fixtures/errors/invalid-option/babel.config.json
at Module.parseSync (<CWD>/packages/babel-core/lib/parse.js:58:72)
at Module.parseSync (<CWD>/packages/babel-core/lib/parse.js:_:_)
... frames from this test file ...
... internal jest frames ..."
`);
Expand All @@ -206,7 +209,7 @@ describe("@babel/core errors", function () {
}),
).toMatchInlineSnapshot(`
"Error: .sourceType must be \\"module\\", \\"script\\", \\"unambiguous\\", or undefined
at Module.parseSync (<CWD>/packages/babel-core/lib/parse.js:58:72)
at Module.parseSync (<CWD>/packages/babel-core/lib/parse.js:_:_)
... frames from this test file ...
... internal jest frames ..."
`);
Expand All @@ -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 (<CWD>/packages/babel-core/lib/config/files/configuration.js:148:47)
at loadOneConfig (<CWD>/packages/babel-core/lib/config/files/configuration.js:_:_)
at loadOneConfig.next (<anonymous>)
at buildRootChain (<CWD>/packages/babel-core/lib/config/config-chain.js:86:51)
at buildRootChain (<CWD>/packages/babel-core/lib/config/config-chain.js:_:_)
at buildRootChain.next (<anonymous>)
at loadPrivatePartialConfig (<CWD>/packages/babel-core/lib/config/partial.js:103:62)
at loadPrivatePartialConfig (<CWD>/packages/babel-core/lib/config/partial.js:_:_)
at loadPrivatePartialConfig.next (<anonymous>)
at loadFullConfig (<CWD>/packages/babel-core/lib/config/full.js:57:46)
at loadFullConfig (<CWD>/packages/babel-core/lib/config/full.js:_:_)
at loadFullConfig.next (<anonymous>)
at parse (<CWD>/packages/babel-core/lib/parse.js:29:45)"
at parse (<CWD>/packages/babel-core/lib/parse.js:_:_)"
`);
});
});

0 comments on commit fefa347

Please sign in to comment.