When using vite, you have a huge ecosystem of plugins to choose from.
If you don't already have a vite app
Create one via:
pnpm dlx ember-cli@latest new demo-terminal-logging-during-ember-browser-testing --pnpm
cd demo-terminal-logging-during-ember-browser-testing
I found https://github.com/patak-dev/vite-plugin-terminal by Patak, one of the vite developers!
Setting this plugin up an an ember project to get browser-test results in the terminal is quite straight-forward:
In your vite config, add the plugin:
+ import Terminal from 'vite-plugin-terminal';
export default defineConfig({
plugins: [
+ Terminal({ console: 'terminal' }),
ember(),
babel({
babelHelpers: 'runtime',
extensions,
}),
],
});
And QUnit doesn't log to the console in /tests mode by default, so let's add some logging in tests/test-helper.js
import * as QUnit from 'qunit';
QUnit.testDone(function (info) {
let status = info.failed === 0 ? '✅' : '❌';
let statusText = info.failed === 0 ? 'passed' : 'failed';
console.group();
console.log(`${status} ${info.module} > ${info.name}: ${statusText}`);
console.log(` Assertions:`);
for (let assertion of info.assertions) {
console.log(` ${assertion.result}: ${assertion.message}`);
}
console.log('');
console.groupEnd();
});
And that's it!
Now when you run tests, you'll get output like this:
» [vite] connected.
» DEBUG: -------------------------------
» DEBUG: Ember : 6.8.1
» DEBUG: -------------------------------
» ✅ example > example test: passed
» Assertions:
» true: okay
»
» ✅ ember-qunit: Ember.onerror validation > Ember.onerror is functioning properly: passed
» Assertions:
» true: Ember.onerror handler with invalid testing behavior detected. An Ember.onerror handler _must_ rethrow exceptions when `Ember.testing` is `true` or the test suite is unreliable. See https://git.io/vbine for more details.
»
Try it out here: https://github.com/NullVoxPopuli/demo-terminal-logging-during-ember-browser-testing
Top comments (0)