Skip to content
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

Create test command #1

Merged
merged 21 commits into from
Jan 24, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*.js.map
!/*.js
!/tasks/*.js
/_build
/bower_components
/dist
/html-report
/node_modules
/typings
.baseDir.ts
.tscache
coverage-unmapped.json
npm-debug.log
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
sudo: false
language: node_js
node_js:
- '6'
env:
global:
- SAUCE_USERNAME: dojo2-ts-ci
- SAUCE_ACCESS_KEY: e92610e3-834e-4bec-a3b5-6f7b9d874601
install:
- travis_retry npm install grunt cli
- travis_retry npm install
script:
- grunt
- grunt intern:node --combined
- grunt remapIstanbul:ci
- grunt uploadCoverage
notifications:
slack:
secure: O9m3cCkl3H8VXRIuKLFfx91C01n9yLlehem9K3snnBMiyrtGWR2aXo+t1eeZYGfFWIl8UBEaSPlDurI1KspIcW/JbszuYAVje21rbl+ptkp008f5gDVfFCFpqdM9S5+lrVJLlx1mrikWKBRsjYqZHYV9EJx/ss+P86JsQ0utC7zgBFYId+UCMybAemzi1FPfeULFWpoi8QavoN8fNr4yHBayrqOlqnnIhlYLoTiGL6yY8L/meUrmWVxSY3JMDxLeIYNppt4puvTGUD1hU2LZgFZp1y6jGMcAlZI5amGV+iyTl/h2w1wiB6q5tolJ1JslosFvh53y7+1Crbm8wQDkX42+z7Rn3/jXRUBFwLZBGZQ99FcE0Yz+XBaQA3GuCgPNd0rcHmJxeYAKMm7jg2B8Nzd6It3q5mjdp9ITA5kR2G7g+iH8R4y112FXCpvt4/RUvHuyhl7w8lFlHK+LslH3DBjDi3fKUuwiGtU8oD3xpCunJ4JUgQmAWIOy3mpFIOX4QPcBKqByp10fNw3G73JDsJ9DXrFGb/+WnA2OgpDnKOnjoporwufRZLeioRwCJAWM0DbFDvRc1mbnECwcKiedzKdTxSWUGyJ6sxKydZtC11tF356BkzIsf3x7cKSed2LI8VXYNiPOJu9P+/s5/jRf/7kZ+i2ETfuKZC2awhgkBGo=
on_success: change
34 changes: 34 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = function (grunt) {
var staticFiles = [ 'intern/**' ];
require('grunt-dojo2').initConfig(grunt, {
ts: {
dist: {
exclude: [
'./src/intern',
'./tests/**/*.ts'
]
}
},
copy: {
staticDistFiles: {
expand: true,
cwd: 'src',
src: staticFiles,
dest: '<%= distDirectory %>'
},
staticDevFiles: {
expand: true,
cwd: 'src',
src: staticFiles,
dest: '<%= devDirectory %>/src'
}
}
});

grunt.registerTask('ci', [
'intern:node'
]);

grunt.registerTask('dist', grunt.config.get('distTasks').concat(['copy:staticDistFiles']));
grunt.registerTask('dev', grunt.config.get('devTasks').concat(['copy:staticDevFiles']));
};
28 changes: 28 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
The "New" BSD License
*********************

Copyright (c) 2015 - 2016, The Dojo Foundation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2017 and JS Foundation.

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the Dojo Foundation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,41 @@
# cli-test-intern
The Dojo 2 cli command for testing applications

<!-- TODO: change and uncomment
[![Build Status](https://travis-ci.org/dojo/cli-test-intern.svg?branch=master)](https://travis-ci.org/dojo/cli-test-intern)
[![codecov](https://codecov.io/gh/dojo/cli-test-intern/branch/master/graph/badge.svg)](https://codecov.io/gh/dojo/cli-test-intern)
[![npm version](https://badge.fury.io/js/dojo-cli-test-intern.svg)](http://badge.fury.io/js/dojo-cli-test-intern)
-->

The official dojo 2 test command.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dojo 2 (capitalization)


## Features
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think we could fill out the readme a bit?


TODO: Add sections on features of this package

## How do I use this package?

TODO: Add appropriate usage and instruction guidelines

## How do I contribute?

We appreciate your interest! Please see the [Dojo 2 Meta Repository](https://github.com/dojo/meta#readme) for the
Contributing Guidelines and Style Guide.

## Testing

Test cases MUST be written using [Intern](https://theintern.github.io) using the Object test interface and Assert assertion interface.

90% branch coverage MUST be provided for all code submitted to this repository, as reported by istanbul’s combined coverage results for all supported platforms.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Istanbul (capitalization)


To test locally in node run:

`grunt test`

## Licensing information

TODO: If third-party code was used to write this library, make a list of project names and licenses here
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably add the dependencies like chalk in here?


* [Third-party lib one](https//github.com/foo/bar) ([New BSD](http://opensource.org/licenses/BSD-3-Clause))

© 2004–2016 Dojo Foundation & contributors. [New BSD](http://opensource.org/licenses/BSD-3-Clause) license.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should now be JS Foundation. Should just link to our own LICENSE file probably.


4 changes: 4 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
comment:
branches:
- master
- feature/*
44 changes: 44 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "dojo-cli-test-intern",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dojo/cli-test-intern

"version": "2.0.0-pre",
"description": "test a dojo 2 application",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test a Dojo 2 application

"private": true,
"homepage": "http://dojotoolkit.org",
"bugs": {
"url": "https://github.com/maier49/cli-test-intern/issues"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably be dojo rather than maier49?

},
"license": "BSD-3-Clause",
"main": "main.js",
"repository": {
"type": "git",
"url": "https://github.com/maier49/cli-test-intern.git"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dojo rather than maier49

},
"scripts": {
"test": "grunt test"
},
"devDependencies": {
"@types/chalk": "^0.4.31",
"codecov.io": "0.1.6",
"dojo-cli": "^2.0.0-alpha.3",
"dojo-loader": ">=2.0.0-beta.7",
"dts-generator": "~1.7.0",
"glob": "^7.0.3",
"grunt": "~1.0.1",
"grunt-tslint": "^3.0.0",
"grunt-dojo2": "^2.0.0-beta.18",
"intern": "~3.3.2",
"istanbul": "^0.4.3",
"mockery": "^1.7.0",
"remap-istanbul": "^0.6.4",
"sinon": "^1.17.5",
"tslint": "^3.15.1",
"typescript": "~2.1.4",
"yargs": "^5.0.0"
},
"dependencies": {
"ora": "^0.3.0",
"chalk": "^1.1.3",
"cross-spawn": "^4.0.0",
"pkg-dir": "^1.0.0"
}
}
1 change: 1 addition & 0 deletions src/dirname.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default __dirname;
15 changes: 15 additions & 0 deletions src/intern/intern-local.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
define([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file seems to mix tabs and spaces

'./intern'
], function (intern) {
intern.tunnel = 'NullTunnel';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to potentially use the SeleniumTunnel for local now?

intern.tunnelOptions = {
hostname: 'localhost',
port: '4444'
};

intern.environments = [
{ browserName: 'chrome' }
];

return intern;
});
30 changes: 30 additions & 0 deletions src/intern/intern-saucelabs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
define([
'./intern'
], function (intern) {

intern.capabilities = {
project: '<%- appName %>',
name: '<%- appName %>',
fixSessionCapabilities: false
};

intern.environments = [
{ browserName: 'internet explorer', version: [ '10.0', '11.0' ], platform: 'Windows 7' },
// { browserName: 'microsoftedge', platform: 'Windows 10' },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edge still doesn't work via Sauce I assume?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some cases yes. For a fresh out of the box sample app it works and adding one or two dummy test cases didn't seem to break it. But in stores or core it still has issues.

{ browserName: 'firefox', version: '43', platform: 'Windows 10' },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we be listing a more recent version of FF also?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated to 49. I was having issues with 50 in testing bot but 49 works fine.

{ browserName: 'chrome', platform: 'Windows 10' },
// { browserName: 'safari', version: '9', platform: 'OS X 10.11' },
{ browserName: 'android', platform: 'Linux', version: '4.4', deviceName: 'Google Nexus 7 HD Emulator' }// ,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also be testing Chrome for Android separately?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I commented this out actually because I don't believe the issue with android on saucelabs have been resolved yet.

// { browserName: 'iphone', version: '9.1', deviceName: 'iPhone 6' }
];

/* SauceLabs supports more max concurrency */
intern.maxConcurrency = 4;

/* SauceLabs combined with Travis often causes functional tests to fail with too short a timeout */
intern.defaultTimeout = 10000;

intern.tunnel = 'SauceLabsTunnel';

return intern;
});
75 changes: 75 additions & 0 deletions src/intern/intern.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
define({
proxyPort: 9000,

// A fully qualified URL to the Intern proxy
proxyUrl: 'http://localhost:9000/',

// Default desired capabilities for all environments. Individual capabilities can be overridden by any of the
// specified browser environments in the `environments` array below as well. See
// https://code.google.com/p/selenium/wiki/DesiredCapabilities for standard Selenium capabilities and
// https://saucelabs.com/docs/additional-config#desired-capabilities for Sauce Labs capabilities.
// Note that the `build` capability will be filled in with the current commit ID from the Travis CI environment
// automatically
capabilities: {
'browserstack.debug': false,
project: '<%- appName %>',
name: '<%- appName %>',
fixSessionCapabilities: false
},

// Browsers to run integration testing against. Note that version numbers must be strings if used with Sauce
// OnDemand. Options that will be permutated are browserName, version, platform, and platformVersion; any other
// capabilities options specified for an environment will be copied as-is
environments: [
{ browserName: 'internet explorer', version: [ '10', '11' ], platform: 'WINDOWS' },
{ browserName: 'firefox', platform: 'WINDOWS' },
{ browserName: 'chrome', platform: 'WINDOWS' }/*,
{ browserName: 'Safari', version: '9', platform: 'OS X' }*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a few more examples should be commented out, e.g other browsers for Mac or Linux?

],

// Maximum number of simultaneous integration tests that should be executed on the remote WebDriver service
maxConcurrency: 2,

// Name of the tunnel class to use for WebDriver tests
tunnel: 'BrowserStackTunnel',

// Support running unit tests from a web server that isn't the intern proxy
initialBaseUrl: (function () {
if (typeof location !== 'undefined' && location.pathname.indexOf('__intern/') > -1) {
return '/';
}
return null;
})(),

// The desired AMD loader to use when running unit tests (client.html/client.js). Omit to use the default Dojo
// loader
loaders: {
'host-browser': 'node_modules/dojo-loader/loader.js',
'host-node': 'dojo-loader'
},

// Configuration options for the module loader; any AMD configuration options supported by the specified AMD loader
// can be used here
loaderOptions: {
// Packages that should be registered with the loader in each testing environment
packages: [
{ name: 'src', location: '_build/src' },
{ name: 'tests', location: '_build/tests' },
{ name: 'dojo', location: 'node_modules/intern/browser_modules/dojo' },
{ name: 'dojo-has', location: 'node_modules/dojo-has' },
{ name: 'dojo-shim', location: 'node_modules/dojo-shim' },
{ name: 'sinon', location: 'node_modules/sinon/pkg', main: 'sinon' }
]
},

// Non-functional test suite(s) to run in each browser
suites: [ 'tests/unit/all' ],

// Functional test suite(s) to run in each browser once non-functional tests are completed
functionalSuites: [ 'tests/functional/all' ],

// A regular expression matching URLs to files that should not be included in code coverage analysis
excludeInstrumentation: /(?:node_modules|bower_components|tests)[\/]/,

defaultTimeout: 5000
});
67 changes: 67 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { Command, Helper } from 'dojo-cli/interfaces';
import { Argv } from 'yargs';
import runTests from './runTests';

export interface TestArgs extends Argv {
environments: string;
config: string;
unit: boolean;
functional: boolean;
reporters: string;
coverage: boolean;
}

const command: Command = {
description: 'test your application',
register(helper: Helper) {
helper.yargs.option('c', {
alias: 'config',
describe: 'Specifies what configuration to test with: browserstack(default), \'saucelabs\', or \'local\'ly.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could also be testingbot or crossbrowsertesting (though perhaps not since we don't include configs for those environments, but perhaps we should)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added configuration for testingbot. It might be documented somewhere but I couldn't see how to set testingbot credentials via environment variables so I also added command line args to specify credentials, and added the same support for browserstack and saucelabs as well.

crossbrowsertesting is not supported by the version of dig dug and intern that the create app cli sets as the application's dependency so I'm thinking we should hold off on adding support for that here until it'll work.

type: 'string'
});

helper.yargs.option('e', {
alias: 'environments',
describe: 'Comma separated list of browsers to run tests in',
type: 'string'
});

helper.yargs.option('r', {
alias: 'reporters',
describe: 'Comma separated list of reporters to use, defaults to Console',
type: 'string'
});

helper.yargs.option('u', {
alias: 'unit',
describe: 'Indicates that only unit tests should be run. By default functional tests and unit tests are run'
});

helper.yargs.option('f', {
alias: 'functional',
describe: 'Indicates that only functional tests should be run. By default functional tests and unit tests are run'
});

helper.yargs.option('cov', {
alias: 'coverage',
describe: 'If specified coverage will be included. This is the same as adding the LcovHtml reporter'
});

return helper.yargs;
},
run(helper: Helper, args: TestArgs) {
return new Promise((resolve, reject) => {
if (!helper.command.exists('build')) {
reject(Error('Required command: \'build\', does not exist'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think we could say, have you npm install @dojo/cli-build? as part of the error?

}
const result = helper.command.run('build', '', <any> { withTests: true });
result.then(
() => {
runTests(args).then(resolve, reject);
},
reject
);
});
}
};
export default command;
Loading