intern-examples icon indicating copy to clipboard operation
intern-examples copied to clipboard

Add pure web example for sites like jsfiddle

Open devpaul opened this issue 7 years ago • 3 comments

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>

devpaul avatar Jun 07 '17 21:06 devpaul

Presumably the test suites would still be in the repo?

jason0x43 avatar Jun 11 '17 23:06 jason0x43

Is it possible to write tests in the HTML file?

devpaul avatar Jun 11 '17 23:06 devpaul

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>

jason0x43 avatar Jun 12 '17 12:06 jason0x43