Permalink
Browse files

feat(requirejs/systemjs): add protractor and jest support

  • Loading branch information...
JeroenVinke committed Jul 19, 2018
1 parent 10d6ff2 commit 4648877d0365103a9c88179bf23ec3a9f7c57fc8
Showing with 118 additions and 243 deletions.
  1. +4 −0 lib/commands/new/buildsystems/cli/integration-test-runner/none.js
  2. +5 −0 lib/commands/new/buildsystems/cli/integration-test-runner/protractor.js
  3. +5 −0 lib/commands/new/buildsystems/cli/unit-test-runners/jest.js
  4. +7 −5 lib/commands/new/buildsystems/cli/unit-test-runners/karma.js
  5. +4 −0 lib/commands/new/buildsystems/general/integration-test-runner/none.js
  6. +40 −0 lib/commands/new/buildsystems/general/integration-test-runner/protractor.js
  7. +2 −5 lib/commands/new/buildsystems/{webpack → general}/unit-test-runners/jasmine.js
  8. +0 −1 lib/commands/new/buildsystems/general/unit-test-runners/jest.js
  9. +1 −29 lib/commands/new/buildsystems/webpack/integration-test-runner/protractor.js
  10. +1 −99 lib/commands/new/buildsystems/webpack/unit-test-runners/jest.js
  11. +1 −41 lib/commands/new/new-application.json
  12. +1 −0 lib/dependencies.json
  13. +16 −0 lib/resources/tasks/protractor.js
  14. +4 −0 lib/resources/tasks/protractor.json
  15. +16 −0 lib/resources/tasks/protractor.ts
  16. +1 −1 lib/resources/test/{webpack/babel → }/e2e/demo.e2e.js
  17. +1 −1 lib/resources/test/{webpack/typescript → }/e2e/demo.e2e.ts
  18. 0 lib/resources/test/{webpack/babel → }/e2e/skeleton.po.js
  19. 0 lib/resources/test/{webpack/typescript → }/e2e/skeleton.po.ts
  20. 0 lib/resources/test/{webpack/babel → }/e2e/welcome.po.js
  21. 0 lib/resources/test/{webpack/typescript → }/e2e/welcome.po.ts
  22. 0 lib/resources/test/{webpack/babel → }/jest-pretest.js
  23. 0 lib/resources/test/{webpack/typescript → }/jest-pretest.ts
  24. +3 −3 lib/resources/test/{webpack/babel/protractor.conf.js → protractor.babel.conf.js}
  25. +2 −3 lib/resources/test/{webpack/typescript/protractor.conf.js → protractor.typescript.conf.js}
  26. 0 lib/resources/test/{webpack/babel → }/unit/.eslintrc
  27. 0 lib/resources/test/{ → unit}/app.spec.js
  28. 0 lib/resources/test/{webpack/typescript → }/unit/app.spec.ts
  29. +0 −24 lib/resources/test/webpack/babel/unit/__snapshots__/welcome.spec.js.snap
  30. +0 −7 lib/resources/test/webpack/babel/unit/app.spec.js
  31. +0 −24 lib/resources/test/webpack/typescript/unit/__snapshots__/welcome.spec.ts.snap
  32. +4 −0 lib/workflow/activities/project-create.js
@@ -0,0 +1,4 @@
'use strict';
module.exports = function(project) {
};
@@ -0,0 +1,5 @@
'use strict';
module.exports = function(project) {
require('../../general/integration-test-runner/protractor')(project);
};
@@ -0,0 +1,5 @@
'use strict';
module.exports = function(project) {
require('../../general/unit-test-runners/jest')(project);
};
@@ -13,10 +13,7 @@ module.exports = function(project) {
).addToContent(
ProjectItem.resource('karma.conf.js', 'content/karma.conf.ext', project.model.transpiler),
project.tests.add(
project.unitTests.add(
ProjectItem.resource('setup.ext', 'test/setup.js', project.model.transpiler),
ProjectItem.resource('app.spec.ext', 'test/app.spec.js', project.model.transpiler)
),
ProjectItem.resource('setup.ext', 'test/setup.js', project.model.transpiler),
ProjectItem.resource('aurelia-karma.js', `test/${project.model.loader.id}.aurelia-karma.js`)
)
).addToDevDependencies(
@@ -30,6 +27,11 @@ module.exports = function(project) {
if (project.model.transpiler.id === 'babel') {
project.addToDevDependencies('karma-babel-preprocessor');
} else {
project.addToDevDependencies('karma-typescript-preprocessor', '@types/jasmine');
project.addToDevDependencies('karma-typescript-preprocessor');
// prevent duplicate typescript definitions
if (!project.model.unitTestRunners.find(x => x.id === 'jest')) {
project.addToDevDependencies('@types/jasmine');
}
}
};
@@ -0,0 +1,4 @@
'use strict';
module.exports = function(project) {
};
@@ -0,0 +1,40 @@
'use strict';
const ProjectItem = require('../../../../../project-item').ProjectItem;
module.exports = function(project) {
let configPath;
if (project.model.transpiler.id === 'typescript') {
project.addToDevDependencies(
'ts-node'
);
// prevent duplicate typescript definitions
if (!project.model.unitTestRunners.find(x => x.id === 'jest')) {
project.addToDevDependencies('@types/jasmine');
}
configPath = 'test/protractor.typescript.conf.js';
} else if (project.model.transpiler.id === 'babel') {
configPath = 'test/protractor.babel.conf.js';
}
project.addToTasks(
ProjectItem.resource('protractor.ext', 'tasks/protractor.ext', project.model.transpiler),
ProjectItem.resource('protractor.json', 'tasks/protractor.json')
).addToDevDependencies(
'aurelia-protractor-plugin',
'protractor',
'gulp-protractor',
'wait-on'
).addToContent(
project.tests.add(
project.e2eTests.add(
ProjectItem.resource('demo.e2e.ext', 'test/e2e/demo.e2e.ext', project.model.transpiler),
ProjectItem.resource('skeleton.po.ext', 'test/e2e/skeleton.po.ext', project.model.transpiler),
ProjectItem.resource('welcome.po.ext', 'test/e2e/welcome.po.ext', project.model.transpiler)
),
ProjectItem.resource('protractor.conf.js', configPath)
)
);
};
@@ -7,13 +7,10 @@ module.exports = function(project) {
'displayName': 'Jasmine'
};
let transpilerId = project.model.transpiler.id;
let testContentRoot = `test/webpack/${transpilerId}`;
project.addToContent(
project.tests.add(
project.unitTests.add(
ProjectItem.resource('app.spec.ext', `${testContentRoot}/unit/app.spec.ext`, project.model.transpiler)
ProjectItem.resource('app.spec.ext', 'test/unit/app.spec.ext', project.model.transpiler)
)
)
);
@@ -22,7 +19,7 @@ module.exports = function(project) {
project.addToContent(
project.tests.add(
project.unitTests.add(
ProjectItem.resource('.eslintrc', `${testContentRoot}/unit/.eslintrc`)
ProjectItem.resource('.eslintrc', 'test/unit/.eslintrc')
)
)
);
@@ -15,7 +15,6 @@ module.exports = function(project) {
).addToDevDependencies(
'jest',
'jest-cli',
'gulp-util',
'plugin-error',
'aurelia-loader-nodejs',
'aurelia-pal-nodejs'
@@ -1,33 +1,5 @@
'use strict';
const ProjectItem = require('../../../../../project-item').ProjectItem;
module.exports = function(project) {
let transpilerId = project.model.transpiler.id;
let testContentRoot = `test/webpack/${transpilerId}`;
if (project.model.transpiler.id === 'babel') {
project.addToDevDependencies(
'ts-node'
);
}
project.addToDevDependencies(
'aurelia-protractor-plugin',
'protractor',
'wait-on'
).addToContent(
project.tests.add(
project.e2eTests.add(
ProjectItem.resource('demo.e2e.ext', `${testContentRoot}/e2e/demo.e2e.ext`, project.model.transpiler),
ProjectItem.resource('skeleton.po.ext', `${testContentRoot}/e2e/skeleton.po.ext`, project.model.transpiler),
ProjectItem.resource('welcome.po.ext', `${testContentRoot}/e2e/welcome.po.ext`, project.model.transpiler)
),
ProjectItem.resource('protractor.conf.js', `${testContentRoot}/protractor.conf.js`)
)
);
// prevent duplicate typescript definitions
if (!project.model.unitTestRunner.find(x => x.id === 'jest')) {
project.addToDevDependencies('@types/jasmine');
}
require('../../general/integration-test-runner/protractor')(project);
};
@@ -1,103 +1,5 @@
'use strict';
const ProjectItem = require('../../../../../project-item').ProjectItem;
module.exports = function(project) {
let configureJasmine = require('./jasmine');
configureJasmine(project);
let transpilerId = project.model.transpiler.id;
let testContentRoot = `test/webpack/${transpilerId}`;
project.addToTasks(
ProjectItem.resource('jest.ext', 'tasks/jest.ext', project.model.transpiler),
ProjectItem.resource('jest.json', 'tasks/jest.json')
).addToContent(
project.tests.add(
ProjectItem.resource('jest-pretest.ext', `${testContentRoot}/jest-pretest.ext`, project.model.transpiler)
)
).addToDevDependencies(
'jest',
'jest-cli',
'plugin-error',
'aurelia-loader-nodejs',
'aurelia-pal-nodejs'
);
if (project.model.transpiler.id === 'babel') {
project.addToDevDependencies(
'babel-jest'
);
project.package.jest = {
modulePaths: [
'<rootDir>/src',
'<rootDir>/node_modules'
],
moduleFileExtensions: [
'js',
'json'
],
transform: {
'^.+\\.jsx?$': 'babel-jest'
},
testRegex: '\\.spec\\.(ts|js)x?$',
setupFiles: [
'<rootDir>/test/jest-pretest.js'
],
testEnvironment: 'node',
collectCoverage: true,
collectCoverageFrom: [
'src/**/*.{js,ts}',
'!**/*.spec.{js,ts}',
'!**/node_modules/**',
'!**/test/**'
],
coverageDirectory: '<rootDir>/test/coverage-jest',
coverageReporters: [
'json',
'lcov',
'text',
'html'
]
};
} else if (project.model.transpiler.id === 'typescript') {
project.addToDevDependencies(
'ts-jest',
'@types/jest'
);
project.package.jest = {
modulePaths: [
'<rootDir>/src',
'<rootDir>/node_modules'
],
moduleFileExtensions: [
'js',
'json',
'ts'
],
transform: {
'^.+\\.(ts|tsx)$': '<rootDir>/node_modules/ts-jest/preprocessor.js'
},
testRegex: '\\.spec\\.(ts|js)x?$',
setupFiles: [
'<rootDir>/test/jest-pretest.ts'
],
testEnvironment: 'node',
collectCoverage: true,
collectCoverageFrom: [
'src/**/*.{js,ts}',
'!**/*.spec.{js,ts}',
'!**/node_modules/**',
'!**/test/**'
],
coverageDirectory: '<rootDir>/test/coverage-jest',
coverageReporters: [
'json',
'lcov',
'text',
'html'
]
};
}
require('../../general/unit-test-runners/jest')(project);
};
@@ -352,7 +352,7 @@
{
"id": 650,
"type": "input-select",
"nextActivity": 660,
"nextActivity": 680,
"question": "What css processor would you like to use?",
"stateProperty": "cssProcessor",
"options": [
@@ -403,46 +403,6 @@
}
]
},
{
"type": "branch-switch",
"id": 660,
"stateProperty": "bundler",
"branches": [
{
"case": "cli",
"nextActivity": 670
},
{
"case": "webpack",
"nextActivity": 680
}
]
},
{
"id": 670,
"type": "input-select",
"nextActivity": 700,
"question": "Would you like to configure unit testing?",
"stateProperty": "unitTestRunner",
"options": [
{
"displayName": "Yes",
"description": "Configure your app with Jasmine and Karma.",
"value": {
"id": "karma",
"displayName": "Karma"
}
},
{
"displayName": "No",
"description": "Skip testing. My code is always perfect anyway.",
"value": {
"id": "none",
"displayName": "None"
}
}
]
},
{
"id": 680,
"type": "input-multiselect",
@@ -54,6 +54,7 @@
"gulp-notify": "^3.2.0",
"gulp-plumber": "^1.2.0",
"gulp-postcss": "^7.0.1",
"gulp-protractor": "^4.1.0",
"gulp-rename": "^1.2.2",
"gulp-sass": "^3.1.0",
"gulp-sourcemaps": "^2.6.4",
@@ -0,0 +1,16 @@
import gulp from 'gulp';
const {protractor, webdriver_update } = require('gulp-protractor');
gulp.task('webdriver_update', webdriver_update);
gulp.task('protractor', (cb) => {
gulp.src(['test/e2e/**/*.e2e.js'], { read: false }).pipe(protractor({
configFile: 'test/protractor.conf.js'
})).on('end', cb);
});
// Setting up the test task
export default gulp.series(
'webdriver_update',
'protractor'
);
@@ -0,0 +1,4 @@
{
"name": "protractor",
"description": "Runs Protractor and reports the results. Start the application before running this task."
}
@@ -0,0 +1,16 @@
import * as gulp from 'gulp';
const {protractor, webdriver_update } = require('gulp-protractor');
gulp.task('webdriver_update', webdriver_update);
gulp.task('protractor', (cb) => {
gulp.src(['test/e2e/**/*.e2e.ts'], { read: false }).pipe(protractor({
configFile: 'test/protractor.conf.js'
})).on('end', cb);
});
// Setting up the test task
export default gulp.series(
'webdriver_update',
'protractor'
);
@@ -14,7 +14,7 @@ describe('aurelia skeleton app', function() {
});
it('should load the page and display the initial page title', async () => {
await expect(await poSkeleton.getCurrentPageTitle()).toBe('Aurelia Navigation Skeleton');
await expect(await poSkeleton.getCurrentPageTitle()).toContain('Aurelia');
});
it('should display greeting', async () => {
@@ -15,7 +15,7 @@ describe('aurelia skeleton app', function() {
});
it('should load the page and display the initial page title', async () => {
await expect(await poSkeleton.getCurrentPageTitle()).toBe('Aurelia Navigation Skeleton');
await expect(await poSkeleton.getCurrentPageTitle()).toContain('Aurelia');
});
it('should display greeting', async () => {
Oops, something went wrong.

0 comments on commit 4648877

Please sign in to comment.