How to use the intern.mode function in intern

To help you get started, we’ve selected a few intern examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github theintern / leadfoot / tests / combined-reporter.ts View on Github external
import * as intern from 'intern';
// TODO: logError does not exist in intern/lib/util
// import * as util from 'intern/lib/util';
import * as fs from 'dojo/node!fs';
import Collector = require('dojo/node!istanbul/lib/collector');
import JsonReporter = require('dojo/node!istanbul/lib/report/json');
import LcovHtmlReporter = require('dojo/node!istanbul/lib/report/html');
import TextReporter = require('dojo/node!istanbul/lib/report/text');
import Test = require('intern/lib/Test');

const collector = new Collector();
let reporters: any = [];

if (intern.mode === 'client') {
	reporters = [new JsonReporter()];
} else {
	reporters = [new TextReporter(), new LcovHtmlReporter()];
}

const reporter = {
	start() {
		console.log('Running ' + intern.mode + ' tests…');
	},

	'/session/start'(remote: { environmentType: string }) {
		console.log('Testing ' + remote.environmentType);
	},

	'/coverage'(sessionId: string, coverage: any) {
		collector.add(coverage);
github theintern / leadfoot / tests / combined-reporter.ts View on Github external
stop() {
		if (intern.mode === 'runner' && fs.existsSync('coverage-final.json')) {
			collector.add(
				JSON.parse(fs.readFileSync('coverage-final.json').toString())
			);
		}

		reporters.forEach(function(reporter: any) {
			reporter.writeReport(collector, true);
		});
	}
};