Skip to content

Commit

Permalink
test: Migrate to Jest (#1596)
Browse files Browse the repository at this point in the history
Jest has the same minimum Node version as Mocha, but comes with a lot of batteries included (eg. coverage, assertions), which helps with making things more predictable.

Most of these changes were made using `jest-codemods`.
  • Loading branch information
fb55 committed Dec 27, 2020
1 parent 64b3a21 commit d60bac9
Show file tree
Hide file tree
Showing 18 changed files with 4,325 additions and 2,421 deletions.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,5 +1,5 @@
node_modules
npm-debug.log
.DS_Store
.nyc_output
/coverage
/docs/out/
2 changes: 1 addition & 1 deletion .prettierignore
@@ -1,3 +1,3 @@
node_modules
.nyc_output
/coverage
docs
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -18,12 +18,12 @@ subl:
@subl lib/ test/ package.json index.js

test-cov:
@./node_modules/.bin/nyc node_modules/.bin/_mocha -- --recursive --reporter $(REPORTER)
@./node_modules/.bin/jest --coverage

# Due to occasional unavailability of the code coverage reporting service, the
# exit status of the command in this recipe may optionally be ignored.
report-cov: test-cov
@./node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls || [ "$(OPTIONAL)" = "true" ]
cat coverage/lcov.info | ./node_modules/.bin/coveralls || [ "$(OPTIONAL)" = "true" ]

travis-test: OPTIONAL = true
travis-test: lint types report-cov
Expand Down
12 changes: 6 additions & 6 deletions lib/api/manipulation.js
Expand Up @@ -246,11 +246,11 @@ function _wrap(insert) {
// (ignore text); stop if no children are found.
var j = 0;

while (elInsertLocation && elInsertLocation.children) {
if (j >= elInsertLocation.children.length) {
break;
}

while (
elInsertLocation &&
elInsertLocation.children &&
j < elInsertLocation.children.length
) {
if (elInsertLocation.children[j].type === 'tag') {
elInsertLocation = elInsertLocation.children[j];
j = 0;
Expand Down Expand Up @@ -425,7 +425,7 @@ exports.wrapAll = function (wrapper) {
while (
elInsertLocation &&
elInsertLocation.children &&
j >= elInsertLocation.children.length
j < elInsertLocation.children.length
) {
if (elInsertLocation.children[j].type === 'tag') {
elInsertLocation = elInsertLocation.children[j];
Expand Down

0 comments on commit d60bac9

Please sign in to comment.