-
Notifications
You must be signed in to change notification settings - Fork 19
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
Use chrome instead of PhantomJS #31
Comments
I'm interested in how this will work. |
Would that make sense for this project though? The project's description is "Run QUnit unit tests in a headless PhantomJS instance.". |
I see your point. It is pretty tightly coupled with PhantomJS. I think if it could be spawned the same way as a child process like PhantomJS is, maybe you could have an option to use Chrome. |
Maybe should be easier now that chrome has headless mode (behind the flag so far): https://www.chromestatus.com/features/5678767817097216 |
A basic example: const puppeteer = require('puppeteer');
const DataURI = require('datauri');
const chalk = require('chalk');
const datauri = new DataURI();
// Create data URI of basic HTML page
// It contains a title element where we change the content via JS
datauri.format('.html', `<!doctype html>
<html>
<head>
<title>Test</title>
<meta charset="utf-8">
</head>
<body>
<h1>Original title</h1>
<script>
document.querySelector('h1').innerText = 'New title';
</script>
</body>
</html>`);
puppeteer.launch().then(async browser => {
const page = await browser.newPage();
await page.goto(datauri.content);
// Load QUnit script
await page.addScriptTag({
url: 'https://cdnjs.cloudflare.com/ajax/libs/qunit/2.4.1/qunit.min.js'
});
// Run tests and return results
const results = await page.evaluate(() => new Promise(function (resolve, reject) {
var details = [];
QUnit.test('Title text', (assert) => {
assert.ok(document.querySelector('h1').innerText === 'New title', 'Title text equals "New title"');
});
QUnit.testDone((result) => details.push(result));
QUnit.done((summary) => {
resolve({
details: details,
summary: summary
});
});
}));
// Very basic reporter
results.details.forEach((test) => {
if (test.failed === 0) {
console.log(chalk.green(`✓ ${test.name}`));
} else {
console.log(chalk.red(`× ${test.name}`));
test.assertions.filter(function(assertion) {
return !assertion.result;
}).forEach(function(assertion) {
console.log(chalk.red(`Failing assertion: ${assertion.message}`));
});
}
});
await browser.close();
}); |
@backflip example of what? |
Sorry, good point. :) I was referring to your message from above:
Just in case you wondered what running QUnit tests in Puppeteer might look like. |
There now exists a node-qunit-puppeteer package, which the grunt-contrib-qunit package has since switched over to. Perhaps gulp-qunit could use this as well? Bumping this because I have proposed to deprecate support for PhantomJS for the next release of QUnit, to drop sometime next year. |
Hi, I am a maintainer of impress.js and I was looking for a way to run the 3D transform integration tests in Google Chrome. The problem is that
gulp-qunit
uses PhantomJS and it doesn't have support for 3D transform, see here for what I have tried so far.Is there any chances this plugin can use Chrome instead of PhantomJS, assuming that Chrome has a proper 3D transform support? Is anyone aware of anything that blocks it from being done in this project?
Ping @jonkemp
The text was updated successfully, but these errors were encountered: