Merge pull request #327 from yavorsky/2.0-stderr
Consider stderr for debug fixtures.
This commit is contained in:
commit
7945c53389
@ -21,23 +21,25 @@ const saveInFiles = files => {
|
||||
});
|
||||
};
|
||||
|
||||
const assertTest = (stdout, stderr, opts) => {
|
||||
stderr = stderr.trim();
|
||||
const testOutputType = (type, stdTarg, opts) => {
|
||||
stdTarg = stdTarg.trim();
|
||||
stdTarg = stdTarg.replace(/\\/g, "/");
|
||||
const optsTarg = opts[type];
|
||||
|
||||
if (stderr) {
|
||||
throw new Error("stderr:\n" + stderr);
|
||||
}
|
||||
|
||||
stdout = stdout.trim();
|
||||
stdout = stdout.replace(/\\/g, "/");
|
||||
|
||||
if (opts.stdout) {
|
||||
const expectStdout = opts.stdout.trim();
|
||||
chai.expect(stdout).to.equal(expectStdout, "stdout didn't match");
|
||||
if (optsTarg) {
|
||||
const expectStdout = optsTarg.trim();
|
||||
chai.expect(stdTarg).to.equal(expectStdout, `${type} didn't match`);
|
||||
} else {
|
||||
const file = path.join(opts.testLoc, "stdout.txt");
|
||||
const file = path.join(opts.testLoc, `${type}.txt`);
|
||||
console.log(`New test file created: ${file}`);
|
||||
fs.outputFileSync(file, stdout);
|
||||
fs.outputFileSync(file, stdTarg);
|
||||
}
|
||||
};
|
||||
|
||||
const assertTest = (stdout, stderr, opts) => {
|
||||
testOutputType("stdout", stdout, opts);
|
||||
if (stderr) {
|
||||
testOutputType("stderr", stderr, opts);
|
||||
}
|
||||
};
|
||||
|
||||
@ -77,6 +79,7 @@ describe("debug output", () => {
|
||||
fs.readdirSync(fixtureLoc).forEach(testName => {
|
||||
if (testName.slice(0, 1) === ".") return;
|
||||
const testLoc = path.join(fixtureLoc, testName);
|
||||
if (testName.slice(0, 1) === ".") return;
|
||||
|
||||
const opts = {
|
||||
args: ["src", "--out-dir", "lib"],
|
||||
@ -84,11 +87,16 @@ describe("debug output", () => {
|
||||
};
|
||||
|
||||
const stdoutLoc = path.join(testLoc, "stdout.txt");
|
||||
const stderrLoc = path.join(testLoc, "stderr.txt");
|
||||
|
||||
if (fs.existsSync(stdoutLoc)) {
|
||||
opts.stdout = helper.readFile(stdoutLoc);
|
||||
}
|
||||
|
||||
if (fs.existsSync(stderrLoc)) {
|
||||
opts.stderr = helper.readFile(stderrLoc);
|
||||
}
|
||||
|
||||
const optionsLoc = path.join(testLoc, "options.json");
|
||||
|
||||
if (!fs.existsSync(optionsLoc)) {
|
||||
|
||||
@ -0,0 +1 @@
|
||||
import 'babel-polyfill';
|
||||
@ -0,0 +1,11 @@
|
||||
{
|
||||
"presets": [
|
||||
["../../lib", {
|
||||
"debug": true,
|
||||
"targets": {
|
||||
"chrome": 55
|
||||
},
|
||||
"useBuiltIns": "usage"
|
||||
}]
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
When setting `useBuiltIns: 'usage'`, polyfills are automatically imported when needed.
|
||||
Please remove the `import 'babel-polyfill'` call or use `useBuiltIns: 'entry'` instead.
|
||||
@ -0,0 +1,16 @@
|
||||
babel-preset-env: `DEBUG` option
|
||||
|
||||
Using targets:
|
||||
{
|
||||
"chrome": "55"
|
||||
}
|
||||
|
||||
Using modules transform: commonjs
|
||||
|
||||
Using plugins:
|
||||
syntax-trailing-function-commas { "chrome":"55" }
|
||||
|
||||
Using polyfills with `usage` option:
|
||||
|
||||
[src/in.js] Based on your code and targets, none were added.
|
||||
src/in.js -> lib/in.js
|
||||
Loading…
x
Reference in New Issue
Block a user