Skip to content

Commit

Permalink
test(): properly resolve path to macro in tests (#1372)
Browse files Browse the repository at this point in the history
  • Loading branch information
timofei-iatsenko authored Jan 27, 2023
1 parent aaae2d6 commit 8881c4a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion packages/babel-plugin-extract-messages/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ function testCase(testName, assertion) {
configFile: false,
plugins: [
"@babel/plugin-syntax-jsx",
"macros",
["macros", {
// macro plugin uses package `resolve` to find a path of macro file
// this will not follow jest pathMapping and will resolve path from ./build
// instead of ./src which makes testing & developing hard.
// here we override resolve and provide correct path for testing
resolvePath: (source: string) => require.resolve(source)
}],
[
plugin,
{
Expand Down
10 changes: 9 additions & 1 deletion packages/macro/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ describe("macro", function () {
filename: "<filename>",
configFile: false,
presets: [],
plugins: ["@babel/plugin-syntax-jsx", "macros"],
plugins: [
"@babel/plugin-syntax-jsx",
["macros", {
// macro plugin uses package `resolve` to find a path of macro file
// this will not follow jest pathMapping and will resolve path from ./build
// instead of ./src which makes testing & developing hard.
// here we override resolve and provide correct path for testing
resolvePath: (source: string) => require.resolve(source)
}]]
}

// return function, so we can test exceptions
Expand Down

1 comment on commit 8881c4a

@vercel
Copy link

@vercel vercel bot commented on 8881c4a Jan 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.