Add windows to travis (#10249)

* Add windows to travis

* Update

* Do not use sh file on windows

* Fix whitespace

* Unify command

* ./ doesn't work on windows

* Remove all ./ usages

* Run windows test before others

* fix: normalize filename when generating sources

sources should be URL.

* fix: replace normalized path to cwd

* chore: add nodePlatform task options

* fix: normalize preset-env filename output

* chore: replace normalized path to CWD on win32 platform

* limit transform-react-source to run on linux and darwin

* test: escapeRegExp on testcases

* test: add test for babel --filename on windows

* test: double babel-node/cli test timeout

* chore: workaround windows build does not stop

* chore: remove redundant condition

* refactor: rename `nodePlatform` to `os`
This commit is contained in:
Nicolò Ribaudo 2019-09-26 20:57:58 +02:00
parent 66062c2a8c
commit b459f6a0a4
No known key found for this signature in database
GPG Key ID: 6F2E38DF3E4A6D0C
21 changed files with 197 additions and 59 deletions

View File

@ -3,12 +3,15 @@ git:
language: node_js language: node_js
cache: cache:
yarn: true yarn: true
os: linux
node_js: node_js:
# We test the latest version on circleci # We test the latest version on circleci
- '11' - "11"
- '10' - "10"
- '8' - "8"
- '6' - "6"
env: env:
global: global:
@ -24,6 +27,7 @@ install:
- if [ "$JOB" = "lint" ]; then make bootstrap; fi - if [ "$JOB" = "lint" ]; then make bootstrap; fi
before_script: before_script:
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then choco install make; fi
- if [ "$JOB" = "babel-parser-flow-tests" ]; then make bootstrap-flow; fi - if [ "$JOB" = "babel-parser-flow-tests" ]; then make bootstrap-flow; fi
- if [ "$JOB" = "babel-parser-test262-tests" ]; then make bootstrap-test262; fi - if [ "$JOB" = "babel-parser-test262-tests" ]; then make bootstrap-test262; fi
@ -36,6 +40,12 @@ script:
matrix: matrix:
fast_finish: true fast_finish: true
include: include:
- os: windows
node_js: "node"
env:
- JOB=test
# https://travis-ci.community/t/build-doesnt-finish-after-completing-tests/288/9
- YARN_GPG=no
- node_js: "node" - node_js: "node"
env: JOB=lint env: JOB=lint
- node_js: "node" - node_js: "node"

View File

@ -10,30 +10,30 @@ SOURCES = packages codemods
.PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap .PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap
build: clean clean-lib build: clean clean-lib
./node_modules/.bin/gulp build yarn gulp build
node ./packages/babel-standalone/scripts/generate.js node packages/babel-standalone/scripts/generate.js
node ./packages/babel-types/scripts/generateTypeHelpers.js node packages/babel-types/scripts/generateTypeHelpers.js
# call build again as the generated files might need to be compiled again. # call build again as the generated files might need to be compiled again.
./node_modules/.bin/gulp build yarn gulp build
# generate flow and typescript typings # generate flow and typescript typings
node packages/babel-types/scripts/generators/flow.js > ./packages/babel-types/lib/index.js.flow node packages/babel-types/scripts/generators/flow.js > packages/babel-types/lib/index.js.flow
node packages/babel-types/scripts/generators/typescript.js > ./packages/babel-types/lib/index.d.ts node packages/babel-types/scripts/generators/typescript.js > packages/babel-types/lib/index.d.ts
ifneq ("$(BABEL_COVERAGE)", "true") ifneq ("$(BABEL_COVERAGE)", "true")
make build-standalone make build-standalone
make build-preset-env-standalone make build-preset-env-standalone
endif endif
build-standalone: build-standalone:
./node_modules/.bin/gulp build-babel-standalone yarn gulp build-babel-standalone
build-preset-env-standalone: build-preset-env-standalone:
./node_modules/.bin/gulp build-babel-preset-env-standalone yarn gulp build-babel-preset-env-standalone
prepublish-build-standalone: prepublish-build-standalone:
BABEL_ENV=production IS_PUBLISH=true ./node_modules/.bin/gulp build-babel-standalone BABEL_ENV=production IS_PUBLISH=true yarn gulp build-babel-standalone
prepublish-build-preset-env-standalone: prepublish-build-preset-env-standalone:
BABEL_ENV=production IS_PUBLISH=true ./node_modules/.bin/gulp build-babel-preset-env-standalone BABEL_ENV=production IS_PUBLISH=true yarn gulp build-babel-preset-env-standalone
build-dist: build build-dist: build
cd packages/babel-polyfill; \ cd packages/babel-polyfill; \
@ -45,28 +45,28 @@ watch: clean clean-lib
# Ensure that build artifacts for types are created during local # Ensure that build artifacts for types are created during local
# development too. # development too.
BABEL_ENV=development ./node_modules/.bin/gulp build-no-bundle BABEL_ENV=development yarn gulp build-no-bundle
node ./packages/babel-types/scripts/generateTypeHelpers.js node packages/babel-types/scripts/generateTypeHelpers.js
node packages/babel-types/scripts/generators/flow.js > ./packages/babel-types/lib/index.js.flow node packages/babel-types/scripts/generators/flow.js > packages/babel-types/lib/index.js.flow
node packages/babel-types/scripts/generators/typescript.js > ./packages/babel-types/lib/index.d.ts node packages/babel-types/scripts/generators/typescript.js > packages/babel-types/lib/index.d.ts
BABEL_ENV=development ./node_modules/.bin/gulp watch BABEL_ENV=development yarn gulp watch
flow: flow:
./node_modules/.bin/flow check --strip-root yarn flow check --strip-root
lint: lint-js lint-ts lint: lint-js lint-ts
lint-js: lint-js:
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' --format=codeframe yarn eslint scripts $(SOURCES) '*.js' --format=codeframe
lint-ts: lint-ts:
./scripts/tests/typescript/lint.sh scripts/tests/typescript/lint.sh
fix: fix-json fix: fix-json
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' --format=codeframe --fix yarn eslint scripts $(SOURCES) '*.js' --format=codeframe --fix
fix-json: fix-json:
./node_modules/.bin/prettier "{packages,codemod}/*/test/fixtures/**/options.json" --write --loglevel warn yarn prettier "{packages,codemod}/*/test/fixtures/**/options.json" --write --loglevel warn
clean: test-clean clean: test-clean
rm -f .npmrc rm -f .npmrc
@ -79,14 +79,18 @@ test-clean:
$(foreach source, $(SOURCES), \ $(foreach source, $(SOURCES), \
$(call clean-source-test, $(source))) $(call clean-source-test, $(source)))
# Does not work on Windows; use "yarn jest" instead
test-only: test-only:
BABEL_ENV=test ./scripts/test.sh BABEL_ENV=test ./scripts/test.sh
make test-clean make test-clean
test: lint test-only test: lint test-only
test-ci: bootstrap test-only test-ci: bootstrap
BABEL_ENV=test yarn jest --maxWorkers=4 --ci
make test-clean
# Does not work on Windows
test-ci-coverage: SHELL:=/bin/bash test-ci-coverage: SHELL:=/bin/bash
test-ci-coverage: test-ci-coverage:
BABEL_COVERAGE=true BABEL_ENV=test make bootstrap BABEL_COVERAGE=true BABEL_ENV=test make bootstrap
@ -94,9 +98,9 @@ test-ci-coverage:
bash <(curl -s https://codecov.io/bash) -f coverage/coverage-final.json bash <(curl -s https://codecov.io/bash) -f coverage/coverage-final.json
bootstrap-flow: bootstrap-flow:
rm -rf ./build/flow rm -rf build/flow
mkdir -p ./build mkdir -p build
git clone --branch=master --single-branch --shallow-since=2018-11-01 https://github.com/facebook/flow.git ./build/flow git clone --branch=master --single-branch --shallow-since=2018-11-01 https://github.com/facebook/flow.git build/flow
cd build/flow && git checkout $(FLOW_COMMIT) cd build/flow && git checkout $(FLOW_COMMIT)
test-flow: test-flow:
@ -108,9 +112,9 @@ test-flow-update-whitelist:
node scripts/tests/flow/run_babel_parser_flow_tests.js --update-whitelist node scripts/tests/flow/run_babel_parser_flow_tests.js --update-whitelist
bootstrap-test262: bootstrap-test262:
rm -rf ./build/test262 rm -rf build/test262
mkdir -p ./build mkdir -p build
git clone --branch=master --single-branch --shallow-since=2019-01-01 https://github.com/tc39/test262.git ./build/test262 git clone --branch=master --single-branch --shallow-since=2019-01-01 https://github.com/tc39/test262.git build/test262
cd build/test262 && git checkout $(TEST262_COMMIT) cd build/test262 && git checkout $(TEST262_COMMIT)
test-test262: test-test262:
@ -121,6 +125,7 @@ test-test262-ci: bootstrap test-test262
test-test262-update-whitelist: test-test262-update-whitelist:
node scripts/tests/test262/run_babel_parser_test262.js --update-whitelist node scripts/tests/test262/run_babel_parser_test262.js --update-whitelist
# Does not work on Windows
clone-license: clone-license:
./scripts/clone-license.sh ./scripts/clone-license.sh
@ -139,11 +144,11 @@ prepublish:
new-version: new-version:
git pull --rebase git pull --rebase
./node_modules/.bin/lerna version --force-publish="@babel/runtime,@babel/runtime-corejs2,@babel/runtime-corejs3,@babel/standalone,@babel/preset-env-standalone" yarn lerna version --force-publish="@babel/runtime,@babel/runtime-corejs2,@babel/runtime-corejs3,@babel/standalone,@babel/preset-env-standalone"
# NOTE: Run make new-version first # NOTE: Run make new-version first
publish: prepublish publish: prepublish
./node_modules/.bin/lerna publish from-git --require-scripts yarn lerna publish from-git --require-scripts
make clean make clean
publish-ci: prepublish publish-ci: prepublish
@ -153,13 +158,13 @@ else
echo "Missing NPM_TOKEN env var" echo "Missing NPM_TOKEN env var"
exit 1 exit 1
endif endif
./node_modules/.bin/lerna publish from-git --require-scripts --yes yarn lerna publish from-git --require-scripts --yes
rm -f .npmrc rm -f .npmrc
make clean make clean
bootstrap-only: clean-all bootstrap-only: clean-all
yarn --ignore-engines yarn --ignore-engines
./node_modules/.bin/lerna bootstrap -- --ignore-engines yarn lerna bootstrap -- --ignore-engines
bootstrap: bootstrap-only bootstrap: bootstrap-only
make build make build

View File

@ -0,0 +1,5 @@
{
"args": ["--filename", "test.js"],
"stderrContains": true,
"os": ["win32"]
}

View File

@ -0,0 +1 @@
SyntaxError: <CWD>\test.js: Unexpected token, expected ";" (2:10)

View File

@ -0,0 +1,3 @@
arr.map(function () {
return $]!;
});

View File

@ -1,4 +1,5 @@
{ {
"args": ["--filename", "test.js"], "args": ["--filename", "test.js"],
"stderrContains": true "stderrContains": true,
"os": ["linux", "darwin"]
} }

View File

@ -185,7 +185,29 @@ fs.readdirSync(fixtureLoc).forEach(function(binName) {
}; };
const optionsLoc = path.join(testLoc, "options.json"); const optionsLoc = path.join(testLoc, "options.json");
if (fs.existsSync(optionsLoc)) merge(opts, require(optionsLoc)); if (fs.existsSync(optionsLoc)) {
const taskOpts = require(optionsLoc);
if (taskOpts.os) {
let os = taskOpts.os;
if (!Array.isArray(os) && typeof os !== "string") {
throw new Error(
`'os' should be either string or string array: ${taskOpts.os}`,
);
}
if (typeof os === "string") {
os = [os];
}
if (!os.includes(process.platform)) {
return;
}
delete taskOpts.os;
}
merge(opts, taskOpts);
}
["stdout", "stdin", "stderr"].forEach(function(key) { ["stdout", "stdin", "stderr"].forEach(function(key) {
const loc = path.join(testLoc, key + ".txt"); const loc = path.join(testLoc, key + ".txt");
@ -205,7 +227,7 @@ fs.readdirSync(fixtureLoc).forEach(function(binName) {
opts.inFiles[".babelrc"] = helper.readFile(babelrcLoc); opts.inFiles[".babelrc"] = helper.readFile(babelrcLoc);
} }
it(testName, buildTest(binName, testName, opts)); it(testName, buildTest(binName, testName, opts), 20000);
}); });
}); });
}); });

View File

@ -1,5 +1,6 @@
import fs from "fs"; import fs from "fs";
import path from "path"; import path from "path";
import escapeRegExp from "lodash/escapeRegExp";
import { loadOptions as loadOptionsOrig } from "../lib"; import { loadOptions as loadOptionsOrig } from "../lib";
function fixture(...args) { function fixture(...args) {
@ -33,7 +34,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
test: new RegExp(fixture("nonexistant-fake")), test: new RegExp(escapeRegExp(fixture("nonexistant-fake"))),
comments: true, comments: true,
}); });
@ -69,7 +70,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
test: new RegExp(fixture("nonexistant-unknown")), test: new RegExp(escapeRegExp(fixture("nonexistant-unknown"))),
comments: true, comments: true,
}); });
@ -107,7 +108,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
test: [new RegExp(fixture("nonexistant-fake"))], test: [new RegExp(escapeRegExp(fixture("nonexistant-fake")))],
comments: true, comments: true,
}); });
@ -143,7 +144,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
test: [new RegExp(fixture("nonexistant-unknown"))], test: [new RegExp(escapeRegExp(fixture("nonexistant-unknown")))],
comments: true, comments: true,
}); });
@ -183,7 +184,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
include: new RegExp(fixture("nonexistant-fake")), include: new RegExp(escapeRegExp(fixture("nonexistant-fake"))),
comments: true, comments: true,
}); });
@ -219,7 +220,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
include: new RegExp(fixture("nonexistant-unknown")), include: new RegExp(escapeRegExp(fixture("nonexistant-unknown"))),
comments: true, comments: true,
}); });
@ -257,7 +258,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
include: [new RegExp(fixture("nonexistant-fake"))], include: [new RegExp(escapeRegExp(fixture("nonexistant-fake")))],
comments: true, comments: true,
}); });
@ -293,7 +294,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
include: [new RegExp(fixture("nonexistant-unknown"))], include: [new RegExp(escapeRegExp(fixture("nonexistant-unknown")))],
comments: true, comments: true,
}); });
@ -333,7 +334,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
exclude: new RegExp(fixture("nonexistant-fake")), exclude: new RegExp(escapeRegExp(fixture("nonexistant-fake"))),
comments: true, comments: true,
}); });
@ -369,7 +370,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
exclude: new RegExp(fixture("nonexistant-unknown")), exclude: new RegExp(escapeRegExp(fixture("nonexistant-unknown"))),
comments: true, comments: true,
}); });
@ -407,7 +408,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
exclude: [new RegExp(fixture("nonexistant-fake"))], exclude: [new RegExp(escapeRegExp(fixture("nonexistant-fake")))],
comments: true, comments: true,
}); });
@ -443,7 +444,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
exclude: [new RegExp(fixture("nonexistant-unknown"))], exclude: [new RegExp(escapeRegExp(fixture("nonexistant-unknown")))],
comments: true, comments: true,
}); });

View File

@ -24,14 +24,20 @@ export default class SourceMap {
const code = this._code; const code = this._code;
if (typeof code === "string") { if (typeof code === "string") {
map.setSourceContent(this._opts.sourceFileName, code); map.setSourceContent(
this._opts.sourceFileName.replace(/\\/g, "/"),
code,
);
} else if (typeof code === "object") { } else if (typeof code === "object") {
Object.keys(code).forEach(sourceFileName => { Object.keys(code).forEach(sourceFileName => {
map.setSourceContent(sourceFileName, code[sourceFileName]); map.setSourceContent(
sourceFileName.replace(/\\/g, "/"),
code[sourceFileName],
);
}); });
} }
this._rawMappings.forEach(map.addMapping, map); this._rawMappings.forEach(mapping => map.addMapping(mapping), map);
} }
return this._cachedMap.toJSON(); return this._cachedMap.toJSON();
@ -83,7 +89,10 @@ export default class SourceMap {
line: generatedLine, line: generatedLine,
column: generatedColumn, column: generatedColumn,
}, },
source: line == null ? undefined : filename || this._opts.sourceFileName, source:
line == null
? undefined
: (filename || this._opts.sourceFileName).replace(/\\/g, "/"),
original: original:
line == null line == null
? undefined ? undefined

View File

@ -192,6 +192,26 @@ export default function get(entryLoc): Array<Suite> {
delete taskOpts.minNodeVersion; delete taskOpts.minNodeVersion;
} }
if (taskOpts.os) {
let os = taskOpts.os;
if (!Array.isArray(os) && typeof os !== "string") {
throw new Error(
`'os' should be either string or string array: ${taskOpts.os}`,
);
}
if (typeof os === "string") {
os = [os];
}
if (!os.includes(process.platform)) {
return;
}
delete taskOpts.os;
}
// traceur checks // traceur checks
if (test.exec.code.indexOf("// Async.") >= 0) { if (test.exec.code.indexOf("// Async.") >= 0) {

View File

@ -295,12 +295,22 @@ function validateFile(actualCode, expectedLoc, expectedCode) {
} }
function normalizeOutput(code) { function normalizeOutput(code) {
return code let result = code
.trim() .trim()
.replace( .replace(
new RegExp(escapeRegExp(path.resolve(__dirname, "../../../")), "g"), new RegExp(escapeRegExp(path.resolve(__dirname, "../../../")), "g"),
"<CWD>", "<CWD>",
); );
if (process.platform === "win32") {
result = result.replace(
new RegExp(
escapeRegExp(path.resolve(__dirname, "../../../").replace(/\\/g, "/")),
"g",
),
"<CWD>",
);
}
return result;
} }
const toEqualFile = () => ({ const toEqualFile = () => ({

View File

@ -198,7 +198,7 @@ fs.readdirSync(fixtureLoc).forEach(function(binName) {
opts.inFiles[".babelrc"] = helper.readFile(babelrcLoc); opts.inFiles[".babelrc"] = helper.readFile(babelrcLoc);
} }
it(testName, buildTest(binName, testName, opts)); it(testName, buildTest(binName, testName, opts), 20000);
}); });
}); });
}); });

View File

@ -0,0 +1,3 @@
{
"os": ["linux", "darwin"]
}

View File

@ -0,0 +1,3 @@
{
"os": ["linux", "darwin"]
}

View File

@ -0,0 +1,3 @@
{
"os": ["linux", "darwin"]
}

View File

@ -56,6 +56,10 @@ export const logEntryPolyfills = (
polyfillTargets: Targets, polyfillTargets: Targets,
allBuiltInsList: { [key: string]: Targets }, allBuiltInsList: { [key: string]: Targets },
) => { ) => {
// normalize filename to generate consistent preset-env test fixtures
if (process.env.BABEL_ENV === "test") {
filename = filename.replace(/\\/g, "/");
}
if (!importPolyfillIncluded) { if (!importPolyfillIncluded) {
console.log(`\n[${filename}] Import of ${polyfillName} was not found.`); console.log(`\n[${filename}] Import of ${polyfillName} was not found.`);
return; return;
@ -83,6 +87,10 @@ export const logUsagePolyfills = (
polyfillTargets: Targets, polyfillTargets: Targets,
allBuiltInsList: { [key: string]: Targets }, allBuiltInsList: { [key: string]: Targets },
) => { ) => {
// normalize filename to generate consistent preset-env test fixtures
if (process.env.BABEL_ENV === "test") {
filename = filename.replace(/\\/g, "/");
}
if (!polyfills.size) { if (!polyfills.size) {
console.log( console.log(
`\n[${filename}] Based on your code and targets, core-js polyfills were not added.`, `\n[${filename}] Based on your code and targets, core-js polyfills were not added.`,

View File

@ -33,8 +33,13 @@ export default function() {
}, },
post() { post() {
if (this.opts.debug && this.regeneratorImportExcluded) { if (this.opts.debug && this.regeneratorImportExcluded) {
let filename = this.file.opts.filename;
// normalize filename to generate consistent preset-env test fixtures
if (process.env.BABEL_ENV === "test") {
filename = filename.replace(/\\/g, "/");
}
console.log( console.log(
`\n[${this.file.opts.filename}] Based on your targets, regenerator-runtime import excluded.`, `\n[${filename}] Based on your targets, regenerator-runtime import excluded.`,
); );
} }
}, },

View File

@ -21,8 +21,13 @@ export default function() {
}, },
post() { post() {
if (this.opts.debug && this.usesRegenerator) { if (this.opts.debug && this.usesRegenerator) {
let filename = this.file.opts.filename;
// normalize filename to generate consistent preset-env test fixtures
if (process.env.BABEL_ENV === "test") {
filename = filename.replace(/\\/g, "/");
}
console.log( console.log(
`\n[${this.file.opts.filename}] Based on your code and targets, added regenerator-runtime.`, `\n[${filename}] Based on your code and targets, added regenerator-runtime.`,
); );
} }
}, },

View File

@ -0,0 +1,19 @@
const actual = transform(
'<Foo bar="baz" />',
Object.assign({}, opts, { filename: 'C:\\fake\\path\\mock.js' })
).code;
const expected = multiline([
'var _jsxFileName = "C:\\\\fake\\\\path\\\\mock.js";',
'React.createElement(Foo, {',
' bar: "baz",',
' __source: {',
' fileName: _jsxFileName,',
' lineNumber: 1',
' },',
' __self: this',
'});',
]);
expect(actual).toBe(expected);

View File

@ -0,0 +1,4 @@
{
"presets": [["react", { "development": true }]],
"os": ["win32"]
}

View File

@ -1,3 +1,4 @@
{ {
"presets": [["react", { "development": true }]] "presets": [["react", { "development": true }]],
"os": ["linux", "darwin"]
} }