Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: highlight browser failures #5218

Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/cli/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ exports.handler = argv => {
const destdir = argv.path;
const srcdir = path.join(__dirname, '..', '..');
fs.mkdirSync(destdir, {recursive: true});
const css = fs.readFileSync(path.join(srcdir, 'mocha.css'));
const css = fs.readFileSync(path.join(srcdir, 'mocha.sass'));
const js = fs.readFileSync(path.join(srcdir, 'mocha.js'));
const tmpl = fs.readFileSync(
path.join(srcdir, 'lib', 'browser', 'template.html')
);
fs.writeFileSync(path.join(destdir, 'mocha.css'), css);
fs.writeFileSync(path.join(destdir, 'mocha.sass'), css);
fs.writeFileSync(path.join(destdir, 'mocha.js'), js);
fs.writeFileSync(path.join(destdir, 'tests.spec.js'), '');
fs.writeFileSync(path.join(destdir, 'index.html'), tmpl);
Expand Down
2 changes: 1 addition & 1 deletion lib/reporters/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ function HTML(runner, options) {
hideSuitesWithout('test fail');
}
});

root.appendChild(stat);
root.appendChild(report);

Expand Down Expand Up @@ -197,6 +196,7 @@ function HTML(runner, options) {
);
}

stat.className += ' fail';
self.addCodeToggle(el, test.body);
appendToStack(el);
updateStats();
Expand Down
10 changes: 10 additions & 0 deletions mocha.css → mocha.sass
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,16 @@ body {
margin: 0;
color: var(--mocha-stats-color);
z-index: 1;
background-color: #00e600;
mark-wiemer marked this conversation as resolved.
Show resolved Hide resolved
border: solid #00e600;
border-radius: 10px;
}

#mocha-stats.fail {
@extend #mocha-stats;
mark-wiemer marked this conversation as resolved.
Show resolved Hide resolved
border: solid #c00;
background-color: #c00;
border-radius: 10px;
}

#mocha-stats .progress-contain {
Expand Down
27 changes: 23 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
"bin/*mocha*",
"lib/**/*.{js,html,json}",
"index.js",
"mocha.css",
"mocha.sass",
"mocha.js",
"mocha.js.map",
"browser-entry.js"
Expand Down
2 changes: 1 addition & 1 deletion test/integration/init.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('init command', function () {
return done(err);
}
expect(result, 'to have succeeded');
expect(fs.existsSync(path.join(tmpdir, 'mocha.css')), 'to be true');
expect(fs.existsSync(path.join(tmpdir, 'mocha.sass')), 'to be true');
expect(fs.existsSync(path.join(tmpdir, 'mocha.js')), 'to be true');
expect(fs.existsSync(path.join(tmpdir, 'tests.spec.js')), 'to be true');
expect(fs.existsSync(path.join(tmpdir, 'index.html')), 'to be true');
Expand Down