Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add default value for browserslist config path (#13159)
- Loading branch information
Showing
5 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...lation-targets/test/load-browserslist-package-json/load-browserslist-package-json.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import getTargets from "../.."; | ||
import { fileURLToPath } from "url"; | ||
import path from "path"; | ||
|
||
const oldCwd = process.cwd(); | ||
|
||
beforeAll(() => { | ||
process.chdir(path.dirname(fileURLToPath(import.meta.url))); | ||
}); | ||
|
||
afterAll(() => { | ||
process.chdir(oldCwd); | ||
}); | ||
|
||
it("loads packageJson.browserslist", () => { | ||
const actual = getTargets({}, {}); | ||
|
||
expect(actual).toEqual({ chrome: "4.0.0" }); | ||
}); |
3 changes: 3 additions & 0 deletions
3
packages/babel-helper-compilation-targets/test/load-browserslist-package-json/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"browserslist": "chrome 4" | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/babel-helper-compilation-targets/test/load-browserslistrc/.browserslistrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
chrome 4 | ||
|
||
[development] | ||
chrome 88 |
30 changes: 30 additions & 0 deletions
30
...ges/babel-helper-compilation-targets/test/load-browserslistrc/load-browserslistrc.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import getTargets from "../.."; | ||
import { fileURLToPath } from "url"; | ||
import path from "path"; | ||
|
||
const oldCwd = process.cwd(); | ||
|
||
beforeAll(() => { | ||
process.chdir(path.dirname(fileURLToPath(import.meta.url))); | ||
}); | ||
|
||
afterAll(() => { | ||
process.chdir(oldCwd); | ||
}); | ||
|
||
it("loads browserslistrc", () => { | ||
const actual = getTargets({}, {}); | ||
|
||
expect(actual).toEqual({ chrome: "4.0.0" }); | ||
}); | ||
|
||
it("loads browserslistrc and respects browserslistEnv", () => { | ||
const actual = getTargets( | ||
{}, | ||
{ | ||
browserslistEnv: "development", | ||
}, | ||
); | ||
|
||
expect(actual).toEqual({ chrome: "88.0.0" }); | ||
}); |