Skip to content

Commit

Permalink
update jest (major), babel-jest (major) (#8341)
Browse files Browse the repository at this point in the history
updated `jest` and `babel-jest` to `v23`

fixed breaking change in `jest`:
- https://github.com/facebook/jest/blob/master/CHANGELOG.md#2300
- jestjs/jest#5558

_edit:_
forgot to mention. test runner fix is based on: https://github.com/babel/babel/blob/master/packages/babel-parser/test/helpers/runFixtureTests.js#L11
  • Loading branch information
dnalborczyk authored and hzoo committed Jul 19, 2018
1 parent c8038f6 commit adae150
Show file tree
Hide file tree
Showing 4 changed files with 351 additions and 288 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -19,7 +19,7 @@
"@babel/register": "7.0.0-beta.52",
"babel-core": "^7.0.0-0",
"babel-eslint": "^8.2.6",
"babel-jest": "^22.4.1",
"babel-jest": "^23.4.0",
"babel-loader": "8.0.0-beta.0",
"babel-plugin-transform-charcodes": "^0.1.0",
"browserify": "^13.1.1",
Expand All @@ -44,7 +44,7 @@
"gulp-util": "^3.0.7",
"gulp-watch": "^5.0.0",
"husky": "^0.14.3",
"jest": "^22.4.2",
"jest": "^23.4.1",
"lerna": "^2.11.0",
"lerna-changelog": "^0.5.0",
"lint-staged": "^6.0.1",
Expand Down
58 changes: 30 additions & 28 deletions packages/babel-generator/test/index.js
Expand Up @@ -362,36 +362,38 @@ const suites = fixtures(`${__dirname}/fixtures`);
suites.forEach(function(testSuite) {
describe("generation/" + testSuite.title, function() {
testSuite.tests.forEach(function(task) {
it(
const testFn = task.disabled ? it.skip : it;

testFn(
task.title,
!task.disabled &&
function() {
const expected = task.expect;
const actual = task.actual;
const actualCode = actual.code;

if (actualCode) {
const actualAst = parse(actualCode, {
filename: actual.loc,
plugins: task.options.plugins || [],
strictMode: false,
sourceType: "module",
});
const result = generate(actualAst, task.options, actualCode);

if (
!expected.code &&
result.code &&
fs.statSync(path.dirname(expected.loc)).isDirectory() &&
!process.env.CI
) {
console.log(`New test file created: ${expected.loc}`);
fs.writeFileSync(expected.loc, result.code);
} else {
expect(result.code).toBe(expected.code);
}

function() {
const expected = task.expect;
const actual = task.actual;
const actualCode = actual.code;

if (actualCode) {
const actualAst = parse(actualCode, {
filename: actual.loc,
plugins: task.options.plugins || [],
strictMode: false,
sourceType: "module",
});
const result = generate(actualAst, task.options, actualCode);

if (
!expected.code &&
result.code &&
fs.statSync(path.dirname(expected.loc)).isDirectory() &&
!process.env.CI
) {
console.log(`New test file created: ${expected.loc}`);
fs.writeFileSync(expected.loc, result.code);
} else {
expect(result.code).toBe(expected.code);
}
},
}
},
);
});
});
Expand Down
60 changes: 30 additions & 30 deletions packages/babel-helper-transform-fixture-test-runner/src/index.js
Expand Up @@ -345,44 +345,44 @@ export default function(
continue;
}

it(
const testFn = task.disabled ? it.skip : it;

testFn(
task.title,
!task.disabled &&
function() {
function runTask() {
run(task);
}

defaults(task.options, {
sourceMap: !!(task.sourceMappings || task.sourceMap),
});
function() {
function runTask() {
run(task);
}

extend(task.options, taskOpts);
defaults(task.options, {
sourceMap: !!(task.sourceMappings || task.sourceMap),
});

if (dynamicOpts) dynamicOpts(task.options, task);
extend(task.options, taskOpts);

const throwMsg = task.options.throws;
if (throwMsg) {
// internal api doesn't have this option but it's best not to pollute
// the options object with useless options
delete task.options.throws;
if (dynamicOpts) dynamicOpts(task.options, task);

assert.throws(runTask, function(err) {
return (
throwMsg === true || err.message.indexOf(throwMsg) >= 0
);
});
} else {
if (task.exec.code) {
const result = run(task);
if (result && typeof result.then === "function") {
return result;
}
} else {
runTask();
const throwMsg = task.options.throws;
if (throwMsg) {
// internal api doesn't have this option but it's best not to pollute
// the options object with useless options
delete task.options.throws;

assert.throws(runTask, function(err) {
return throwMsg === true || err.message.indexOf(throwMsg) >= 0;
});
} else {
if (task.exec.code) {
const result = run(task);
if (result && typeof result.then === "function") {
return result;
}
} else {
runTask();
}
},
}
},
);
}
});
Expand Down

0 comments on commit adae150

Please sign in to comment.