intern-examples
intern-examples copied to clipboard
Add pure web example for sites like jsfiddle
As a user, I'd like to be able to write intern tests that run purely in the browser. For example, I may want to produce a test for a project like DefintielyTyped that prevents me from adding a package.json file to a sub-directory; or I may want to share tests on jsfiddle, dojo.io, or in workshops.
Long story short, it'd be awesome to get an example that can show people that intern can do this and how to get started :heart:
Here's my started code. I haven't yet gotten it working due to theintern/intern#747
<!DOCTYPE html>
<html lang="en">
<head>
<title>Unit Tests</title>
<script src="https://unpkg.com/intern@next/browser/intern.js"></script>
</head>
</html>
Presumably the test suites would still be in the repo?
Is it possible to write tests in the HTML file?
It is. You can currently do something like:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Unit Tests</title>
<script src="https://unpkg.com/intern@next/browser/intern.js"></script>
<script>
var registerSuite = intern.getPlugin('interface.object').registerSuite;
registerSuite('suiteA', {
test1: function () { ... },
test2: function () { ... }
});
intern.configure({ reporters: 'html' });
intern.run();
</script>
</head>
</html>