Skip to content

Commit

Permalink
Merge pull request #1071 from marko-js/jsdom-context-require
Browse files Browse the repository at this point in the history
switch to using extracted jsdom-context-require
  • Loading branch information
mlrawlings authored Jun 28, 2018
2 parents 47e2dfe + 5729a7e commit 1e4c5ce
Show file tree
Hide file tree
Showing 13 changed files with 209 additions and 394 deletions.
6 changes: 3 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ npm run test-coverage
While developing you can run a single test group and use [grep](https://mochajs.org/#-g---grep-pattern) to filter the tests:

```
npm run mocha -- --grep=lifecycle
npm test -- --grep=lifecycle
```

### Adding tests
Expand Down Expand Up @@ -89,7 +89,7 @@ Expected failures won't cause [Travis CI](https://travis-ci.org/marko-js/marko)
If you need to dig a bit deeper into a failing test, use the `--inspect-brk` flag, open Chrome DevTools, and click on the green nodejs icon (<img height="16" src="https://user-images.githubusercontent.com/1958812/37050480-d53e4276-2128-11e8-8c7a-f5d842956c98.png"/>) to start debugging. Learn more about [debugging node](https://www.youtube.com/watch?v=Xb_0awoShR8&t=103s) from this video.

```
npm run mocha -- --grep=test-name --inspect-brk
npm test -- --grep=test-name --inspect-brk
```

In addition to [setting breakpoints](https://developers.google.com/web/tools/chrome-devtools/javascript/breakpoints), you can also add [`debugger;`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger) statements in both your JavaScript files and Marko templates:
Expand All @@ -106,7 +106,7 @@ A number of the test suites make use snapshot comparisons. For example, the `ren
To update a snapshot, you can copy the contents from the `actual` file to the `expected` file in the fixture directory. You can also use the `UPDATE_EXPECTATIONS` env variable to cause the test runner to update the `expected` file for all currently failing tests in a suite:

```
UPDATE_EXPECTATIONS=1 npm run mocha
UPDATE_EXPECTATIONS=1 npm test
```

## Tackling an existing issue
Expand Down
258 changes: 184 additions & 74 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
"build-src": "node scripts/build.js src",
"prepublish": "npm run build-src",
"precommit": "lint-staged",
"test": "npm run lint -s && npm run mocha -s",
"test-ci": "npm run check-format && npm run test-generate-coverage",
"mocha": "mocha --timeout 10000 --max-old-space-size=768 ./test/*/*.test.js",
"test": "mocha --timeout 10000 ./test/*/*.test.js",
"test-ci": "npm run lint && npm run check-format && npm run test-generate-coverage",
"test-coverage": "npm run test-generate-coverage && nyc report --reporter=html && opn ./coverage/index.html",
"test-generate-coverage": "nyc -asc npm test",
"lint": "eslint .",
Expand Down Expand Up @@ -82,7 +81,7 @@
"istanbul-lib-instrument": "^1.8.0",
"it-fails": "^1.0.0",
"jquery": "^3.1.1",
"jsdom": "^9.12.0",
"jsdom-context-require": "^1.0.1",
"lasso-resolve-from": "^1.2.0",
"lint-staged": "^7.0.0",
"marko-widgets": "^7.0.1",
Expand Down
2 changes: 1 addition & 1 deletion test/__util__/BrowserHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ BrowserHelpers.prototype = {
},

cleanPath: function(path) {
return path.replace(/\.\d+\.in-module-context$/, "");
return path.replace(/\.\d+\.in-context$/, "");
}
};

Expand Down
187 changes: 0 additions & 187 deletions test/__util__/create-context-module.js

This file was deleted.

107 changes: 0 additions & 107 deletions test/__util__/create-jsdom-module.js

This file was deleted.

4 changes: 2 additions & 2 deletions test/__util__/create-marko-jsdom-module.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

const jQuery = require("jquery");
const createJSDOMModule = require("./create-jsdom-module");
const createBrowser = require("jsdom-context-require");
const compiler = require("../../compiler");
const noop = function() {};
const globals = [
Expand Down Expand Up @@ -32,7 +32,7 @@ const browserExtensions = {

module.exports = function(dir, html, options) {
options = options || {};
return createJSDOMModule({
return createBrowser({
dir: dir,
html: html,
extensions: browserExtensions,
Expand Down
8 changes: 4 additions & 4 deletions test/__util__/runRenderTest.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

const createJSDOMModule = require("../__util__/create-jsdom-module");
const defaultDocument = createJSDOMModule({
const createBrowser = require("jsdom-context-require");
const defaultDocument = createBrowser({
dir: __dirname,
html: "<html><body></body></html>"
}).window.document;
Expand Down Expand Up @@ -182,7 +182,7 @@ module.exports = function runRenderTest(dir, snapshot, done, options) {

let expectedHtmlPath = path.join(dir, "expected.html");
let html = fs.readFileSync(expectedHtmlPath, "utf-8");
let browser = createJSDOMModule({
let browser = createBrowser({
dir: __dirname,
html: "<html><body>" + html + "</body></html>"
});
Expand Down Expand Up @@ -216,7 +216,7 @@ module.exports = function runRenderTest(dir, snapshot, done, options) {

let vdomHtml = domToHTML(actualNode);

let browser = createJSDOMModule({
let browser = createBrowser({
dir: __dirname,
html: "<html><body>" + vdomHtml + "</body></html>"
});
Expand Down
Loading

0 comments on commit 1e4c5ce

Please sign in to comment.