Skip to content

Commit

Permalink
Upgrade to Intern 4.
Browse files Browse the repository at this point in the history
  • Loading branch information
wkeese committed Jul 19, 2019
1 parent 6e93bcf commit cee494a
Show file tree
Hide file tree
Showing 14 changed files with 276 additions and 220 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
.idea
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"maxlen": 120,
"indent": 4,
"maxerr": 250,
"predef": [ "require", "define" ],
"predef": [ "require", "define", "intern" ],
"quotmark": "double",
"maxcomplexity": 10
}
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ install:
- npm install
- bower install
script:
- grunt jshint test:remote
- grunt jshint
- npx intern config=@sauce
env:
global:
# ibm-js
Expand Down
54 changes: 1 addition & 53 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,20 @@
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),

jshint: {
src: [
"**/*.js", "!{node_modules,dev}/**"
],
options: {
jshintrc: ".jshintrc"
}
},

intern: {
// run tests on local desktop browser(s)
local: {
options: {
runType: "runner",
config: "tests/intern/local",
reporters: ["runner"]
}
},
// run tests on remote cloud service
remote: {
options: {
runType: "runner",
config: "tests/intern/saucelab",
reporters: ["runner"]
}
}
}
});

// Load plugins
grunt.loadNpmTasks("intern");
grunt.loadNpmTasks("grunt-contrib-jshint");

// Aliases
grunt.registerTask("default", ["jshint"]);

// Testing.
// always specify the target e.g. grunt test:remote, grunt test:remote
// then add on any other flags afterwards e.g. console, lcovhtml
var testTaskDescription = "Run this task instead of the intern task directly! \n" +
"Always specify the test target e.g. \n" +
"grunt test:local\n" +
"grunt test:local.android\n" +
"grunt test:local.ios\n" +
"grunt test:remote\n\n" +
"Add any optional reporters via a flag e.g. \n" +
"grunt test:local:console\n" +
"grunt test:local:lcovhtml\n" +
"grunt test:local:console:lcovhtml";
grunt.registerTask("test", testTaskDescription, function (target) {
function addReporter(reporter) {
var property = "intern." + target + ".options.reporters",
value = grunt.config.get(property);
if (value.indexOf(reporter) !== -1) {
return;
}
value.push(reporter);
grunt.config.set(property, value);
}
if (this.flags.lcovhtml) {
addReporter("lcovhtml");
}
if (this.flags.console) {
addReporter("console");
}
grunt.task.run("intern:" + target);
});
};
24 changes: 24 additions & 0 deletions intern-requirejs-loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// From https://stackoverflow.com/questions/54925478/how-do-i-configure-intern-4-to-use-requirejs/54927704#54927704
/* globals Promise, requirejs */
intern.registerLoader(function (options) {
function initLoader(requirejs) {
// Configure requireJS -- use options passed in through the intern.json
// config, and add anything else.
requirejs.config(options);

// This is the function Intern will actually call to load modules.
return function (modules) {
return new Promise(function (resolve, reject) {
requirejs(modules, resolve, reject);
});
};
}

if (typeof window !== "undefined") {
return intern.loadScript("decor/node_modules/requirejs/require.js").then(function () {
return initLoader(requirejs);
});
} else {
return initLoader(require("requirejs"));
}
});
236 changes: 236 additions & 0 deletions intern.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
{
"environments": [
{
"browserName": "chrome",
"chromeOptions": {
"args": ["headless", "disable-gpu"]
},
"fixSessionCapabilities": "no-detect"
}
],

"leaveRemoteOpen": false,

"basePath": "../",

"node": {
"loader": {
"script": "./intern-requirejs-loader.js",
"options": {
"baseUrl": "."
}
}
},

"browser": {
"loader": {
"script": "dpointer/intern-requirejs-loader.js",
"options": {
"baseUrl": "../../..",
"packages": [
{ "name": "intern", "location": "dpointer/node_modules/intern" }
]
}
}
},

"suites": [
"dpointer/tests/unit/dpointer-utils"
],

"functionalSuites": [
],

"coverage": [
"**/*.js",
"!nls/**",
"!node_modules/**",
"!samples/**",
"!tests/**",
"!intern*",
"!Gruntfile.js"
],

"tunnelOptions": {
"drivers": [ "firefox", "internet explorer", "MicrosoftEdge" ]
},

"WAIT_TIMEOUT": 30000,
"POLL_INTERVAL": 500,

"defaultTimeout": 120000,
"functionalTimeouts": {
"connectTimeout": 60000,
"executeAsync": 30000,
"find": 10000,
"pageLoad": 60000
},

"configs": {
"chrome-debug": {
"description": "Run locally with Chrome visible and leave it open at end",
"leaveRemoteOpen": true,
"environments": [
{ "browser": "chrome", "fixSessionCapabilities": false }
]
},

"firefox": {
"description": "Run locally with Firefox",
"environments": [
{
"browserName": "firefox",
"fixSessionCapabilities": false,
"moz:firefoxOptions": {
"args": [
"-headless", "--window-size=1024,768"
]
}
}
]
},

"firefox-debug": {
"description": "Run locally with Firefox visible and leave it open at end",
"leaveRemoteOpen": true,
"environments": [
{ "browser": "firefox", "fixSessionCapabilities": false }
]
},

"safari": {
"description": "Run locally with Safari visible and leave it open at end",
"leaveRemoteOpen": true,
"environments": [
{ "browser": "safari", "fixSessionCapabilities": false }
]
},

"grid": {
"description": "Run tests against selenium grid, must specify serverUrl and tunnelOptions.hostname on command line",
"tunnel": "null",
"environments": [
{ "browser": "chrome" }
]
},

"browserstack": {
"description": "Run tests on BrowserStack.",
"tunnel": "browserstack",
"maxConcurrency": 2,
"capabilities": {
"idle-timeout": 60,
"fixSessionCapabilities": "no-detect"
},
"environments": [
{ "browser": "internet explorer", "version": ["11"] },
{
"browser": "firefox",
"version": ["latest"],
"platform": ["WINDOWS"]
},
{
"browser": "chrome",
"version": ["latest"],
"platform": ["WINDOWS"]
},
{ "browser": "safari", "version": ["10"] }
]
},

"browserstack-ie": {
"description": "Run tests on IE on BrowserStack.",
"extends": ["browserstack"],
"environments": [
{ "browserName": "internet explorer", "version": "11", "name": "dpointer"}
]
},

"sauce": {
"description": "Run tests on SauceLabs",
"environments": [
{ "browserName": "MicrosoftEdge", "fixSessionCapabilities": false, "name": "dpointer"},
{ "browserName": "internet explorer", "version": "11", "fixSessionCapabilities": false, "name": "dpointer"},
{ "browserName": "firefox", "platform": [ "Windows 10" ], "fixSessionCapabilities": false, "name": "dpointer" },
{ "browserName": "chrome", "platform": [ "Windows 10" ], "fixSessionCapabilities": false, "name": "dpointer" },
{ "browserName": "safari", "fixSessionCapabilities": false, "name": "dpointer" }
],

"proxyPort": 9000,
"maxConcurrency": 5,
"coverage": false,
"tunnel": "saucelabs"
},

"sauce-chrome": {
"description": "Run tests on Chrome/Windows 10 on SauceLabs",
"environments": [
{ "browserName": "chrome", "platform": [ "Windows 10" ], "fixSessionCapabilities": false, "name": "dpointer" }
],

"proxyPort": 9000,
"maxConcurrency": 5,
"coverage": false,
"tunnel": "saucelabs"
},

"sauce-firefox ": {
"description": "Run tests on Firefox/Windows 10 on SauceLabs",
"environments": [
{ "browserName": "firefox", "platform": [ "Windows 10" ], "fixSessionCapabilities": false, "name": "dpointer" }
],

"proxyPort": 9000,
"maxConcurrency": 5,
"coverage": false,
"tunnel": "saucelabs"
},

"sauce-ie": {
"description": "Run tests on IE on SauceLabs.",
"extends": ["sauce"],
"environments": [
{ "browserName": "internet explorer", "version": "11", "fixSessionCapabilities": "no-detect",
"name": "dpointer" }
],
"coverage": null
},

"sauce-safari": {
"description": "Run tests on Safari (Mac) on SauceLabs",
"environments": [
{ "browserName": "safari", "fixSessionCapabilities": false, "name": "dpointer" }
],

"proxyPort": 9000,
"maxConcurrency": 5,
"coverage": false,
"tunnel": "saucelabs"
},

"sauce-ios": {
"description": "Run tests on iOS on SauceLabs (currently hangs).",
"extends": [
"sauce"
],
"environments": [
{ "browserName": "Safari", "platformName": "iOS", "platformVersion": "12.2", "deviceName": "iPad Simulator",
"fixSessionCapabilities": "no-detect", "name": "dpointer" }
],
"coverage": null
},

"sauce-android": {
"description": "Run tests on android on SauceLabs.",
"extends": [
"sauce"
],
"environments": [
{ "browserName": "android", "platform": "Linux", "version": "6.0", "deviceName": "Android Emulator",
"deviceType": "tablet", "fixSessionCapabilities": "no-detect", "name": "dpointer" }
],
"coverage": null
}

}
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"name": "dpointer",
"version": "0.5.2",
"devDependencies": {
"intern": "1.6.x",
"intern": "4.4.x",
"grunt": "~0.4.2",
"grunt-contrib-jshint": "~0.6.3"
"grunt-contrib-jshint": "~0.6.3",
"requirejs": "2.1.x"
},
"licenses": [
{
Expand Down
15 changes: 0 additions & 15 deletions tests/intern/TestUtils.js

This file was deleted.

Loading

0 comments on commit cee494a

Please sign in to comment.