Skip to content

Commit

Permalink
Docs: Test React example reports errors
Browse files Browse the repository at this point in the history
  • Loading branch information
btmills committed Aug 1, 2020
1 parent e51daaf commit a10d6dc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"scripts": {
"lint": "eslint --ext js,md .",
"test": "npm run lint && npm run test-cov",
"test-cov": "nyc _mocha -- -c tests/lib/**/*.js",
"test-cov": "nyc _mocha -- -c tests/{examples,lib}/**/*.js",
"generate-release": "eslint-generate-release",
"generate-alpharelease": "eslint-generate-prerelease alpha",
"generate-betarelease": "eslint-generate-prerelease beta",
Expand Down
25 changes: 25 additions & 0 deletions tests/examples/react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"use strict";

const assert = require("chai").assert;
const execSync = require("child_process").execSync;
const path = require("path");

describe("examples", () => {
describe("react", () => {
it("reports errors on jsx code blocks in .md files", () => {
try {
execSync("npx eslint . --format json", {
cwd: path.resolve(__dirname, "../../examples/react/")
});
assert.fail("ESLint should have found issues.");
} catch (error) {
const results = JSON.parse(error.stdout.toString());
const readme = results.find(result =>
path.basename(result.filePath) == "README.md"
);
assert.isNotNull(readme);
assert.isAbove(readme.messages.length, 0);
}
});
});
});

0 comments on commit a10d6dc

Please sign in to comment.