From ea4ce1af3c5c1c07683c9f72c1b128f6b1907286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Wenzel?= Date: Thu, 10 May 2018 13:30:21 +0200 Subject: [PATCH] feat(new-application): add scaffolding feature for navigation skeleton --- .../project-definitions.json | 71 +++++++++++++++++++ ...ton-requirejs-esnext-jest-aspnetcore.json} | 21 +++--- ...on => skeleton-requirejs-esnext-jest.json} | 21 +++--- ...ton-requirejs-esnext-karma-aspnetcore.json | 46 ++++++++++++ .../skeleton-requirejs-esnext-karma.json | 46 ++++++++++++ ...requirejs-typescript-jest-aspnetcore.json} | 21 +++--- ...> skeleton-requirejs-typescript-jest.json} | 21 +++--- ...requirejs-typescript-karma-aspnetcore.json | 46 ++++++++++++ .../skeleton-requirejs-typescript-karma.json | 46 ++++++++++++ ...eton-systemjs-esnext-jest-aspnetcore.json} | 21 +++--- ...son => skeleton-systemjs-esnext-jest.json} | 21 +++--- ...eton-systemjs-esnext-karma-aspnetcore.json | 46 ++++++++++++ .../skeleton-systemjs-esnext-karma.json | 46 ++++++++++++ ...-systemjs-typescript-jest-aspnetcore.json} | 21 +++--- ...=> skeleton-systemjs-typescript-jest.json} | 21 +++--- ...-systemjs-typescript-karma-aspnetcore.json | 46 ++++++++++++ .../skeleton-systemjs-typescript-karma.json | 46 ++++++++++++ ...leton-webpack-esnext-jest-aspnetcore.json} | 21 +++--- ...json => skeleton-webpack-esnext-jest.json} | 21 +++--- ...leton-webpack-esnext-karma-aspnetcore.json | 53 ++++++++++++++ .../skeleton-webpack-esnext-karma.json | 53 ++++++++++++++ ...n-webpack-typescript-jest-aspnetcore.json} | 21 +++--- ... => skeleton-webpack-typescript-jest.json} | 21 +++--- ...n-webpack-typescript-karma-aspnetcore.json | 53 ++++++++++++++ .../skeleton-webpack-typescript-karma.json | 53 ++++++++++++++ lib/commands/new/buildsystems/cli/index.js | 25 +++---- .../cli/unit-test-runners/karma.js | 21 ++++-- .../integration-test-runner/protractor.js | 12 ++-- .../general/unit-test-runners/jasmine.js | 15 +++- .../new/buildsystems/webpack/index.js | 15 ++-- .../buildsystems/webpack/transpilers/babel.js | 5 +- .../webpack/unit-test-runners/karma.js | 5 +- lib/commands/new/new-application.json | 51 ++++--------- lib/commands/new/project-template.js | 2 +- lib/dependencies.json | 2 +- lib/resources/content/karma.conf.js | 2 +- lib/resources/content/karma.conf.ts | 2 +- lib/resources/content/tsconfig.template.json | 2 +- lib/resources/features/bootstrap.js | 15 ++-- lib/resources/features/fontAwesome.js | 8 +-- lib/resources/features/jquery.js | 10 +-- lib/resources/features/navigation/welcome.js | 2 + lib/resources/features/navigation/welcome.ts | 2 + lib/resources/src/app.template.html | 6 +- lib/resources/src/app.template.js | 4 ++ lib/resources/src/main-webpack.template.js | 2 +- lib/resources/test/e2e/demo.e2e.template.js | 54 ++++++++++++++ lib/resources/test/e2e/demo.e2e.template.ts | 55 ++++++++++++++ lib/resources/test/e2e/demo.e2e.ts | 12 ++-- .../test/e2e/skeleton.po.template.js | 13 ++++ .../test/e2e/skeleton.po.template.ts | 15 ++++ lib/resources/test/e2e/skeleton.po.ts | 2 +- lib/resources/test/e2e/welcome.po.template.js | 46 ++++++++++++ lib/resources/test/e2e/welcome.po.template.ts | 50 +++++++++++++ lib/resources/test/e2e/welcome.po.ts | 2 +- lib/resources/test/unit/app.spec.template.js | 52 ++++++++++++++ lib/resources/test/unit/app.spec.template.ts | 53 ++++++++++++++ lib/resources/test/unit/child-router.spec.js | 42 +++++++++++ lib/resources/test/unit/child-router.spec.ts | 42 +++++++++++ lib/resources/test/unit/users.spec.js | 30 ++++++++ lib/resources/test/unit/users.spec.ts | 36 ++++++++++ .../test/webpack/babel/karma-bundle.js | 37 ---------- .../test/webpack/typescript/karma-bundle.js | 37 ---------- lib/workflow/activities/project-create.js | 10 ++- package-lock.json | 32 ++++----- spec/lib/workflow/state-assign.spec.js | 4 +- 66 files changed, 1379 insertions(+), 356 deletions(-) create mode 100644 lib/commands/generate-skeletons/project-definitions.json rename lib/commands/generate-skeletons/project-definitions/{skeleton-requirejs-esnext-aspnetcore.json => skeleton-requirejs-esnext-jest-aspnetcore.json} (80%) rename lib/commands/generate-skeletons/project-definitions/{skeleton-requirejs-esnext.json => skeleton-requirejs-esnext-jest.json} (81%) create mode 100644 lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-esnext-karma-aspnetcore.json create mode 100644 lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-esnext-karma.json rename lib/commands/generate-skeletons/project-definitions/{skeleton-requirejs-typescript-aspnetcore.json => skeleton-requirejs-typescript-jest-aspnetcore.json} (80%) rename lib/commands/generate-skeletons/project-definitions/{skeleton-requirejs-typescript.json => skeleton-requirejs-typescript-jest.json} (81%) create mode 100644 lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-typescript-karma-aspnetcore.json create mode 100644 lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-typescript-karma.json rename lib/commands/generate-skeletons/project-definitions/{skeleton-systemjs-esnext-aspnetcore.json => skeleton-systemjs-esnext-jest-aspnetcore.json} (80%) rename lib/commands/generate-skeletons/project-definitions/{skeleton-systemjs-esnext.json => skeleton-systemjs-esnext-jest.json} (81%) create mode 100644 lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-esnext-karma-aspnetcore.json create mode 100644 lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-esnext-karma.json rename lib/commands/generate-skeletons/project-definitions/{skeleton-systemjs-typescript-aspnetcore.json => skeleton-systemjs-typescript-jest-aspnetcore.json} (80%) rename lib/commands/generate-skeletons/project-definitions/{skeleton-systemjs-typescript.json => skeleton-systemjs-typescript-jest.json} (81%) create mode 100644 lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-typescript-karma-aspnetcore.json create mode 100644 lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-typescript-karma.json rename lib/commands/generate-skeletons/project-definitions/{skeleton-webpack-esnext-aspnetcore.json => skeleton-webpack-esnext-jest-aspnetcore.json} (80%) rename lib/commands/generate-skeletons/project-definitions/{skeleton-webpack-esnext.json => skeleton-webpack-esnext-jest.json} (81%) create mode 100644 lib/commands/generate-skeletons/project-definitions/skeleton-webpack-esnext-karma-aspnetcore.json create mode 100644 lib/commands/generate-skeletons/project-definitions/skeleton-webpack-esnext-karma.json rename lib/commands/generate-skeletons/project-definitions/{skeleton-webpack-typescript-aspnetcore.json => skeleton-webpack-typescript-jest-aspnetcore.json} (80%) rename lib/commands/generate-skeletons/project-definitions/{skeleton-webpack-typescript.json => skeleton-webpack-typescript-jest.json} (81%) create mode 100644 lib/commands/generate-skeletons/project-definitions/skeleton-webpack-typescript-karma-aspnetcore.json create mode 100644 lib/commands/generate-skeletons/project-definitions/skeleton-webpack-typescript-karma.json create mode 100644 lib/resources/test/e2e/demo.e2e.template.js create mode 100644 lib/resources/test/e2e/demo.e2e.template.ts create mode 100644 lib/resources/test/e2e/skeleton.po.template.js create mode 100644 lib/resources/test/e2e/skeleton.po.template.ts create mode 100644 lib/resources/test/e2e/welcome.po.template.js create mode 100644 lib/resources/test/e2e/welcome.po.template.ts create mode 100644 lib/resources/test/unit/app.spec.template.js create mode 100644 lib/resources/test/unit/app.spec.template.ts create mode 100644 lib/resources/test/unit/child-router.spec.js create mode 100644 lib/resources/test/unit/child-router.spec.ts create mode 100644 lib/resources/test/unit/users.spec.js create mode 100644 lib/resources/test/unit/users.spec.ts diff --git a/lib/commands/generate-skeletons/project-definitions.json b/lib/commands/generate-skeletons/project-definitions.json new file mode 100644 index 000000000..846f333ac --- /dev/null +++ b/lib/commands/generate-skeletons/project-definitions.json @@ -0,0 +1,71 @@ +{ + "type": [ + "project:application" + ], + "bundler": [ + { + "id": "webpack", + "displayName": "Webpack" + } + ], + "build": [ + { + "options": { + "server": "dev", + "extractCss": "prod", + "coverage": false + } + } + ], + "platform": [ + { + "id": "aspnetcore", + "displayName": "ASP.NET Core" + } + ], + "loader": [ + { + "id": "none", + "displayName": "None" + } + ], + "transpiler": [ + { + "id": "typescript", + "displayName": "TypeScript", + "fileExtension": ".ts" + } + ], + "markupProcessor": [ + { + "id": "minimum", + "displayName": "Minimal Minification", + "fileExtension": ".html" + } + ], + "cssProcessor": [ + { + "id": "none", + "displayName": "None", + "fileExtension": ".css" + } + ], + "editor": [ + { + "id": "vscode", + "displayName": "Visual Studio Code" + } + ], + "unitTestRunner": [ + { + "id": "jest", + "displayName": "Jest" + } + ], + "integrationTestRunner": [ + { + "id": "protractor", + "displayName": "Protractor" + } + ] +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-esnext-aspnetcore.json b/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-esnext-jest-aspnetcore.json similarity index 80% rename from lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-esnext-aspnetcore.json rename to lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-esnext-jest-aspnetcore.json index 330235bcc..199a400e1 100644 --- a/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-esnext-aspnetcore.json +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-esnext-jest-aspnetcore.json @@ -1,5 +1,5 @@ { - "name": "skeleton-requirejs-esnext-aspnetcore", + "name": "skeleton-requirejs-esnext-jest-aspnetcore", "type": "project:application", "bundler": { "id": "cli", @@ -37,18 +37,15 @@ "id": "vscode", "displayName": "Visual Studio Code" }, - "unitTestRunners": [ - { - "id": "jest", - "displayName": "Jest" - }, - { - "id": "karma", - "displayName": "Karma" - } - ], + "unitTestRunner": { + "id": "jest", + "displayName": "Jest" + }, "integrationTestRunner": { "id": "protractor", "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" } -} \ No newline at end of file +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-esnext.json b/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-esnext-jest.json similarity index 81% rename from lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-esnext.json rename to lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-esnext-jest.json index b2d2daf8a..ed7bddf2c 100644 --- a/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-esnext.json +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-esnext-jest.json @@ -1,5 +1,5 @@ { - "name": "skeleton-requirejs-esnext", + "name": "skeleton-requirejs-esnext-jest", "type": "project:application", "bundler": { "id": "cli", @@ -37,18 +37,15 @@ "id": "vscode", "displayName": "Visual Studio Code" }, - "unitTestRunners": [ - { - "id": "jest", - "displayName": "Jest" - }, - { - "id": "karma", - "displayName": "Karma" - } - ], + "unitTestRunner": { + "id": "jest", + "displayName": "Jest" + }, "integrationTestRunner": { "id": "protractor", "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" } -} \ No newline at end of file +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-esnext-karma-aspnetcore.json b/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-esnext-karma-aspnetcore.json new file mode 100644 index 000000000..89bacfd03 --- /dev/null +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-esnext-karma-aspnetcore.json @@ -0,0 +1,46 @@ +{ + "name": "skeleton-requirejs-esnext-karma-aspnetcore", + "type": "project:application", + "bundler": { + "id": "cli", + "displayName": "Aurelia-CLI" + }, + "platform": { + "id": "aspnetcore", + "displayName": "ASP.NET Core" + }, + "loader": { + "id": "require", + "displayName": "RequireJS" + }, + "transpiler": { + "id": "babel", + "displayName": "Babel", + "fileExtension": ".js" + }, + "markupProcessor": { + "id": "minimum", + "displayName": "Minimal Minification", + "fileExtension": ".html" + }, + "cssProcessor": { + "id": "none", + "displayName": "None", + "fileExtension": ".css" + }, + "editor": { + "id": "vscode", + "displayName": "Visual Studio Code" + }, + "unitTestRunner": { + "id": "karma", + "displayName": "Karma" + }, + "integrationTestRunner": { + "id": "protractor", + "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" + } +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-esnext-karma.json b/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-esnext-karma.json new file mode 100644 index 000000000..88b3499a6 --- /dev/null +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-esnext-karma.json @@ -0,0 +1,46 @@ +{ + "name": "skeleton-requirejs-esnext-karma", + "type": "project:application", + "bundler": { + "id": "cli", + "displayName": "Aurelia-CLI" + }, + "platform": { + "id": "web", + "displayName": "Web" + }, + "loader": { + "id": "require", + "displayName": "RequireJS" + }, + "transpiler": { + "id": "babel", + "displayName": "Babel", + "fileExtension": ".js" + }, + "markupProcessor": { + "id": "minimum", + "displayName": "Minimal Minification", + "fileExtension": ".html" + }, + "cssProcessor": { + "id": "none", + "displayName": "None", + "fileExtension": ".css" + }, + "editor": { + "id": "vscode", + "displayName": "Visual Studio Code" + }, + "unitTestRunner": { + "id": "karma", + "displayName": "Karma" + }, + "integrationTestRunner": { + "id": "protractor", + "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" + } +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-typescript-aspnetcore.json b/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-typescript-jest-aspnetcore.json similarity index 80% rename from lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-typescript-aspnetcore.json rename to lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-typescript-jest-aspnetcore.json index c28797c7e..d1a498d5d 100644 --- a/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-typescript-aspnetcore.json +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-typescript-jest-aspnetcore.json @@ -1,5 +1,5 @@ { - "name": "skeleton-requirejs-typescript-aspnetcore", + "name": "skeleton-requirejs-typescript-jest-aspnetcore", "type": "project:application", "bundler": { "id": "cli", @@ -37,18 +37,15 @@ "id": "vscode", "displayName": "Visual Studio Code" }, - "unitTestRunners": [ - { - "id": "jest", - "displayName": "Jest" - }, - { - "id": "karma", - "displayName": "Karma" - } - ], + "unitTestRunner": { + "id": "jest", + "displayName": "Jest" + }, "integrationTestRunner": { "id": "protractor", "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" } -} \ No newline at end of file +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-typescript.json b/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-typescript-jest.json similarity index 81% rename from lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-typescript.json rename to lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-typescript-jest.json index 8c32a8df6..9a59fc633 100644 --- a/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-typescript.json +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-typescript-jest.json @@ -1,5 +1,5 @@ { - "name": "skeleton-requirejs-typescript", + "name": "skeleton-requirejs-typescript-jest", "type": "project:application", "bundler": { "id": "cli", @@ -37,18 +37,15 @@ "id": "vscode", "displayName": "Visual Studio Code" }, - "unitTestRunners": [ - { - "id": "jest", - "displayName": "Jest" - }, - { - "id": "karma", - "displayName": "Karma" - } - ], + "unitTestRunner": { + "id": "jest", + "displayName": "Jest" + }, "integrationTestRunner": { "id": "protractor", "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" } -} \ No newline at end of file +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-typescript-karma-aspnetcore.json b/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-typescript-karma-aspnetcore.json new file mode 100644 index 000000000..2c9673a80 --- /dev/null +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-typescript-karma-aspnetcore.json @@ -0,0 +1,46 @@ +{ + "name": "skeleton-requirejs-typescript-karma-aspnetcore", + "type": "project:application", + "bundler": { + "id": "cli", + "displayName": "Aurelia-CLI" + }, + "platform": { + "id": "aspnetcore", + "displayName": "ASP.NET Core" + }, + "loader": { + "id": "require", + "displayName": "RequireJS" + }, + "transpiler": { + "id": "typescript", + "displayName": "TypeScript", + "fileExtension": ".ts" + }, + "markupProcessor": { + "id": "minimum", + "displayName": "Minimal Minification", + "fileExtension": ".html" + }, + "cssProcessor": { + "id": "none", + "displayName": "None", + "fileExtension": ".css" + }, + "editor": { + "id": "vscode", + "displayName": "Visual Studio Code" + }, + "unitTestRunner": { + "id": "karma", + "displayName": "Karma" + }, + "integrationTestRunner": { + "id": "protractor", + "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" + } +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-typescript-karma.json b/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-typescript-karma.json new file mode 100644 index 000000000..51b40703b --- /dev/null +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-requirejs-typescript-karma.json @@ -0,0 +1,46 @@ +{ + "name": "skeleton-requirejs-typescript-karma", + "type": "project:application", + "bundler": { + "id": "cli", + "displayName": "Aurelia-CLI" + }, + "platform": { + "id": "web", + "displayName": "Web" + }, + "loader": { + "id": "require", + "displayName": "RequireJS" + }, + "transpiler": { + "id": "typescript", + "displayName": "TypeScript", + "fileExtension": ".ts" + }, + "markupProcessor": { + "id": "minimum", + "displayName": "Minimal Minification", + "fileExtension": ".html" + }, + "cssProcessor": { + "id": "none", + "displayName": "None", + "fileExtension": ".css" + }, + "editor": { + "id": "vscode", + "displayName": "Visual Studio Code" + }, + "unitTestRunner": { + "id": "karma", + "displayName": "Karma" + }, + "integrationTestRunner": { + "id": "protractor", + "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" + } +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-esnext-aspnetcore.json b/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-esnext-jest-aspnetcore.json similarity index 80% rename from lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-esnext-aspnetcore.json rename to lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-esnext-jest-aspnetcore.json index aeea7b0fe..a3d739518 100644 --- a/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-esnext-aspnetcore.json +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-esnext-jest-aspnetcore.json @@ -1,5 +1,5 @@ { - "name": "skeleton-systemjs-esnext-aspnetcore", + "name": "skeleton-systemjs-esnext-jest-aspnetcore", "type": "project:application", "bundler": { "id": "cli", @@ -37,18 +37,15 @@ "id": "vscode", "displayName": "Visual Studio Code" }, - "unitTestRunners": [ - { - "id": "jest", - "displayName": "Jest" - }, - { - "id": "karma", - "displayName": "Karma" - } - ], + "unitTestRunner": { + "id": "jest", + "displayName": "Jest" + }, "integrationTestRunner": { "id": "protractor", "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" } -} \ No newline at end of file +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-esnext.json b/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-esnext-jest.json similarity index 81% rename from lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-esnext.json rename to lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-esnext-jest.json index 4c6b25198..bec2d591d 100644 --- a/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-esnext.json +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-esnext-jest.json @@ -1,5 +1,5 @@ { - "name": "skeleton-systemjs-esnext", + "name": "skeleton-systemjs-esnext-jest", "type": "project:application", "bundler": { "id": "cli", @@ -37,18 +37,15 @@ "id": "vscode", "displayName": "Visual Studio Code" }, - "unitTestRunners": [ - { - "id": "jest", - "displayName": "Jest" - }, - { - "id": "karma", - "displayName": "Karma" - } - ], + "unitTestRunner": { + "id": "jest", + "displayName": "Jest" + }, "integrationTestRunner": { "id": "protractor", "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" } -} \ No newline at end of file +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-esnext-karma-aspnetcore.json b/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-esnext-karma-aspnetcore.json new file mode 100644 index 000000000..d69663cf7 --- /dev/null +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-esnext-karma-aspnetcore.json @@ -0,0 +1,46 @@ +{ + "name": "skeleton-systemjs-esnext-karma-aspnetcore", + "type": "project:application", + "bundler": { + "id": "cli", + "displayName": "Aurelia-CLI" + }, + "platform": { + "id": "aspnetcore", + "displayName": "ASP.NET Core" + }, + "loader": { + "id": "system", + "displayName": "SystemJS" + }, + "transpiler": { + "id": "babel", + "displayName": "Babel", + "fileExtension": ".js" + }, + "markupProcessor": { + "id": "minimum", + "displayName": "Minimal Minification", + "fileExtension": ".html" + }, + "cssProcessor": { + "id": "none", + "displayName": "None", + "fileExtension": ".css" + }, + "editor": { + "id": "vscode", + "displayName": "Visual Studio Code" + }, + "unitTestRunner": { + "id": "karma", + "displayName": "Karma" + }, + "integrationTestRunner": { + "id": "protractor", + "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" + } +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-esnext-karma.json b/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-esnext-karma.json new file mode 100644 index 000000000..1fae6d6ae --- /dev/null +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-esnext-karma.json @@ -0,0 +1,46 @@ +{ + "name": "skeleton-systemjs-esnext-karma", + "type": "project:application", + "bundler": { + "id": "cli", + "displayName": "Aurelia-CLI" + }, + "platform": { + "id": "web", + "displayName": "Web" + }, + "loader": { + "id": "system", + "displayName": "SystemJS" + }, + "transpiler": { + "id": "babel", + "displayName": "Babel", + "fileExtension": ".js" + }, + "markupProcessor": { + "id": "minimum", + "displayName": "Minimal Minification", + "fileExtension": ".html" + }, + "cssProcessor": { + "id": "none", + "displayName": "None", + "fileExtension": ".css" + }, + "editor": { + "id": "vscode", + "displayName": "Visual Studio Code" + }, + "unitTestRunner": { + "id": "karma", + "displayName": "Karma" + }, + "integrationTestRunner": { + "id": "protractor", + "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" + } +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-typescript-aspnetcore.json b/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-typescript-jest-aspnetcore.json similarity index 80% rename from lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-typescript-aspnetcore.json rename to lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-typescript-jest-aspnetcore.json index 09e6db6d1..27850484d 100644 --- a/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-typescript-aspnetcore.json +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-typescript-jest-aspnetcore.json @@ -1,5 +1,5 @@ { - "name": "skeleton-systemjs-typescript-aspnetcore", + "name": "skeleton-systemjs-typescript-jest-aspnetcore", "type": "project:application", "bundler": { "id": "cli", @@ -37,18 +37,15 @@ "id": "vscode", "displayName": "Visual Studio Code" }, - "unitTestRunners": [ - { - "id": "jest", - "displayName": "Jest" - }, - { - "id": "karma", - "displayName": "Karma" - } - ], + "unitTestRunner": { + "id": "jest", + "displayName": "Jest" + }, "integrationTestRunner": { "id": "protractor", "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" } -} \ No newline at end of file +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-typescript.json b/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-typescript-jest.json similarity index 81% rename from lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-typescript.json rename to lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-typescript-jest.json index df0ec9224..ba75114ea 100644 --- a/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-typescript.json +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-typescript-jest.json @@ -1,5 +1,5 @@ { - "name": "skeleton-systemjs-typescript", + "name": "skeleton-systemjs-typescript-jest", "type": "project:application", "bundler": { "id": "cli", @@ -37,18 +37,15 @@ "id": "vscode", "displayName": "Visual Studio Code" }, - "unitTestRunners": [ - { - "id": "jest", - "displayName": "Jest" - }, - { - "id": "karma", - "displayName": "Karma" - } - ], + "unitTestRunner": { + "id": "jest", + "displayName": "Jest" + }, "integrationTestRunner": { "id": "protractor", "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" } -} \ No newline at end of file +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-typescript-karma-aspnetcore.json b/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-typescript-karma-aspnetcore.json new file mode 100644 index 000000000..5668bae93 --- /dev/null +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-typescript-karma-aspnetcore.json @@ -0,0 +1,46 @@ +{ + "name": "skeleton-systemjs-typescript-karma-aspnetcore", + "type": "project:application", + "bundler": { + "id": "cli", + "displayName": "Aurelia-CLI" + }, + "platform": { + "id": "aspnetcore", + "displayName": "ASP.NET Core" + }, + "loader": { + "id": "system", + "displayName": "SystemJS" + }, + "transpiler": { + "id": "typescript", + "displayName": "TypeScript", + "fileExtension": ".ts" + }, + "markupProcessor": { + "id": "minimum", + "displayName": "Minimal Minification", + "fileExtension": ".html" + }, + "cssProcessor": { + "id": "none", + "displayName": "None", + "fileExtension": ".css" + }, + "editor": { + "id": "vscode", + "displayName": "Visual Studio Code" + }, + "unitTestRunner": { + "id": "karma", + "displayName": "Karma" + }, + "integrationTestRunner": { + "id": "protractor", + "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" + } +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-typescript-karma.json b/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-typescript-karma.json new file mode 100644 index 000000000..76292199f --- /dev/null +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-systemjs-typescript-karma.json @@ -0,0 +1,46 @@ +{ + "name": "skeleton-systemjs-typescript-karma", + "type": "project:application", + "bundler": { + "id": "cli", + "displayName": "Aurelia-CLI" + }, + "platform": { + "id": "web", + "displayName": "Web" + }, + "loader": { + "id": "system", + "displayName": "SystemJS" + }, + "transpiler": { + "id": "typescript", + "displayName": "TypeScript", + "fileExtension": ".ts" + }, + "markupProcessor": { + "id": "minimum", + "displayName": "Minimal Minification", + "fileExtension": ".html" + }, + "cssProcessor": { + "id": "none", + "displayName": "None", + "fileExtension": ".css" + }, + "editor": { + "id": "vscode", + "displayName": "Visual Studio Code" + }, + "unitTestRunner": { + "id": "karma", + "displayName": "Karma" + }, + "integrationTestRunner": { + "id": "protractor", + "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" + } +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-esnext-aspnetcore.json b/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-esnext-jest-aspnetcore.json similarity index 80% rename from lib/commands/generate-skeletons/project-definitions/skeleton-webpack-esnext-aspnetcore.json rename to lib/commands/generate-skeletons/project-definitions/skeleton-webpack-esnext-jest-aspnetcore.json index d14bf6367..6629ba2b4 100644 --- a/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-esnext-aspnetcore.json +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-esnext-jest-aspnetcore.json @@ -1,5 +1,5 @@ { - "name": "skeleton-webpack-esnext-aspnetcore", + "name": "skeleton-webpack-esnext-jest-aspnetcore", "type": "project:application", "bundler": { "id": "webpack", @@ -39,18 +39,15 @@ "id": "vscode", "displayName": "Visual Studio Code" }, - "unitTestRunners": [ - { - "id": "jest", - "displayName": "Jest" - }, - { - "id": "karma", - "displayName": "Karma" - } - ], + "unitTestRunner": { + "id": "jest", + "displayName": "Jest" + }, "integrationTestRunner": { "id": "protractor", "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" } -} \ No newline at end of file +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-esnext.json b/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-esnext-jest.json similarity index 81% rename from lib/commands/generate-skeletons/project-definitions/skeleton-webpack-esnext.json rename to lib/commands/generate-skeletons/project-definitions/skeleton-webpack-esnext-jest.json index be5c4a664..3f92c861e 100644 --- a/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-esnext.json +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-esnext-jest.json @@ -1,5 +1,5 @@ { - "name": "skeleton-webpack-esnext", + "name": "skeleton-webpack-esnext-jest", "type": "project:application", "bundler": { "id": "webpack", @@ -39,18 +39,15 @@ "id": "vscode", "displayName": "Visual Studio Code" }, - "unitTestRunners": [ - { - "id": "jest", - "displayName": "Jest" - }, - { - "id": "karma", - "displayName": "Karma" - } - ], + "unitTestRunner": { + "id": "jest", + "displayName": "Jest" + }, "integrationTestRunner": { "id": "protractor", "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" } -} \ No newline at end of file +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-esnext-karma-aspnetcore.json b/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-esnext-karma-aspnetcore.json new file mode 100644 index 000000000..933108c4c --- /dev/null +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-esnext-karma-aspnetcore.json @@ -0,0 +1,53 @@ +{ + "name": "skeleton-webpack-esnext-karma-aspnetcore", + "type": "project:application", + "bundler": { + "id": "webpack", + "displayName": "Webpack" + }, + "build": { + "options": { + "server": "dev", + "extractCss": "prod", + "coverage": false + } + }, + "platform": { + "id": "aspnetcore", + "displayName": "ASP.NET Core" + }, + "loader": { + "id": "none", + "displayName": "None" + }, + "transpiler": { + "id": "babel", + "displayName": "Babel", + "fileExtension": ".js" + }, + "markupProcessor": { + "id": "minimum", + "displayName": "Minimal Minification", + "fileExtension": ".html" + }, + "cssProcessor": { + "id": "none", + "displayName": "None", + "fileExtension": ".css" + }, + "editor": { + "id": "vscode", + "displayName": "Visual Studio Code" + }, + "unitTestRunner": { + "id": "karma", + "displayName": "Karma" + }, + "integrationTestRunner": { + "id": "protractor", + "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" + } +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-esnext-karma.json b/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-esnext-karma.json new file mode 100644 index 000000000..132f6f4b8 --- /dev/null +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-esnext-karma.json @@ -0,0 +1,53 @@ +{ + "name": "skeleton-webpack-esnext-karma", + "type": "project:application", + "bundler": { + "id": "webpack", + "displayName": "Webpack" + }, + "build": { + "options": { + "server": "dev", + "extractCss": "prod", + "coverage": false + } + }, + "platform": { + "id": "web", + "displayName": "Web" + }, + "loader": { + "id": "none", + "displayName": "None" + }, + "transpiler": { + "id": "babel", + "displayName": "Babel", + "fileExtension": ".js" + }, + "markupProcessor": { + "id": "minimum", + "displayName": "Minimal Minification", + "fileExtension": ".html" + }, + "cssProcessor": { + "id": "none", + "displayName": "None", + "fileExtension": ".css" + }, + "editor": { + "id": "vscode", + "displayName": "Visual Studio Code" + }, + "unitTestRunner": { + "id": "karma", + "displayName": "Karma" + }, + "integrationTestRunner": { + "id": "protractor", + "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" + } +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-typescript-aspnetcore.json b/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-typescript-jest-aspnetcore.json similarity index 80% rename from lib/commands/generate-skeletons/project-definitions/skeleton-webpack-typescript-aspnetcore.json rename to lib/commands/generate-skeletons/project-definitions/skeleton-webpack-typescript-jest-aspnetcore.json index f868243ba..a1a4f2e1d 100644 --- a/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-typescript-aspnetcore.json +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-typescript-jest-aspnetcore.json @@ -1,5 +1,5 @@ { - "name": "skeleton-webpack-typescript-aspnetcore", + "name": "skeleton-webpack-typescript-jest-aspnetcore", "type": "project:application", "bundler": { "id": "webpack", @@ -39,18 +39,15 @@ "id": "vscode", "displayName": "Visual Studio Code" }, - "unitTestRunners": [ - { - "id": "jest", - "displayName": "Jest" - }, - { - "id": "karma", - "displayName": "Karma" - } - ], + "unitTestRunner": { + "id": "jest", + "displayName": "Jest" + }, "integrationTestRunner": { "id": "protractor", "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" } -} \ No newline at end of file +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-typescript.json b/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-typescript-jest.json similarity index 81% rename from lib/commands/generate-skeletons/project-definitions/skeleton-webpack-typescript.json rename to lib/commands/generate-skeletons/project-definitions/skeleton-webpack-typescript-jest.json index 9ede2235e..65b2ac7c9 100644 --- a/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-typescript.json +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-typescript-jest.json @@ -1,5 +1,5 @@ { - "name": "skeleton-webpack-typescript", + "name": "skeleton-webpack-typescript-jest", "type": "project:application", "bundler": { "id": "webpack", @@ -39,18 +39,15 @@ "id": "vscode", "displayName": "Visual Studio Code" }, - "unitTestRunners": [ - { - "id": "jest", - "displayName": "Jest" - }, - { - "id": "karma", - "displayName": "Karma" - } - ], + "unitTestRunner": { + "id": "jest", + "displayName": "Jest" + }, "integrationTestRunner": { "id": "protractor", "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" } -} \ No newline at end of file +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-typescript-karma-aspnetcore.json b/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-typescript-karma-aspnetcore.json new file mode 100644 index 000000000..9c50e9179 --- /dev/null +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-typescript-karma-aspnetcore.json @@ -0,0 +1,53 @@ +{ + "name": "skeleton-webpack-typescript-karma-aspnetcore", + "type": "project:application", + "bundler": { + "id": "webpack", + "displayName": "Webpack" + }, + "build": { + "options": { + "server": "dev", + "extractCss": "prod", + "coverage": false + } + }, + "platform": { + "id": "aspnetcore", + "displayName": "ASP.NET Core" + }, + "loader": { + "id": "none", + "displayName": "None" + }, + "transpiler": { + "id": "typescript", + "displayName": "TypeScript", + "fileExtension": ".ts" + }, + "markupProcessor": { + "id": "minimum", + "displayName": "Minimal Minification", + "fileExtension": ".html" + }, + "cssProcessor": { + "id": "none", + "displayName": "None", + "fileExtension": ".css" + }, + "editor": { + "id": "vscode", + "displayName": "Visual Studio Code" + }, + "unitTestRunner": { + "id": "karma", + "displayName": "Karma" + }, + "integrationTestRunner": { + "id": "protractor", + "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" + } +} diff --git a/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-typescript-karma.json b/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-typescript-karma.json new file mode 100644 index 000000000..5237e9917 --- /dev/null +++ b/lib/commands/generate-skeletons/project-definitions/skeleton-webpack-typescript-karma.json @@ -0,0 +1,53 @@ +{ + "name": "skeleton-webpack-typescript-karma", + "type": "project:application", + "bundler": { + "id": "webpack", + "displayName": "Webpack" + }, + "build": { + "options": { + "server": "dev", + "extractCss": "prod", + "coverage": false + } + }, + "platform": { + "id": "web", + "displayName": "Web" + }, + "loader": { + "id": "none", + "displayName": "None" + }, + "transpiler": { + "id": "typescript", + "displayName": "TypeScript", + "fileExtension": ".ts" + }, + "markupProcessor": { + "id": "minimum", + "displayName": "Minimal Minification", + "fileExtension": ".html" + }, + "cssProcessor": { + "id": "none", + "displayName": "None", + "fileExtension": ".css" + }, + "editor": { + "id": "vscode", + "displayName": "Visual Studio Code" + }, + "unitTestRunner": { + "id": "karma", + "displayName": "Karma" + }, + "integrationTestRunner": { + "id": "protractor", + "displayName": "Protractor" + }, + "features": { + "navigation": "navigation" + } +} diff --git a/lib/commands/new/buildsystems/cli/index.js b/lib/commands/new/buildsystems/cli/index.js index c52098c4c..fb0c15258 100644 --- a/lib/commands/new/buildsystems/cli/index.js +++ b/lib/commands/new/buildsystems/cli/index.js @@ -3,7 +3,7 @@ const ProjectItem = require('../../../../project-item').ProjectItem; const path = require('path'); -module.exports = function(project, options) { +module.exports = function (project, options) { let model = project.model; let configurePlatform = require(`./platforms/${model.platform.id}`); @@ -21,12 +21,10 @@ module.exports = function(project, options) { let configureJsonProcessor = require(`./json-processors/${model.jsonProcessor.id}`); configureJsonProcessor(project, options); - let unitTestRunners = project.model.unitTestRunners; - if (unitTestRunners) { - for (let i = 0; i < unitTestRunners.length; i++) { - let configureUnitTestRunner = require(`./unit-test-runners/${unitTestRunners[i].id}`); - configureUnitTestRunner(project); - } + let unitTestRunner = project.model.unitTestRunner; + if (unitTestRunner) { + let configureUnitTestRunner = require(`./unit-test-runners/${unitTestRunner.id}`); + configureUnitTestRunner(project); } if (model.integrationTestRunner) { @@ -100,12 +98,11 @@ module.exports = function(project, options) { } if (project.unitTests.parent) { - for (let testRunner of model.unitTestRunners) { - testRunner.source = path.posix.join( - project.unitTests.calculateRelativePath(project.root), - '**/*' + model.transpiler.fileExtension - ); - } + let testRunner = model.unitTestRunner; + testRunner.source = path.posix.join( + project.unitTests.calculateRelativePath(project.root), + '**/*' + model.transpiler.fileExtension + ); } for (let featureName in model.features) { @@ -114,7 +111,7 @@ module.exports = function(project, options) { project.addToSource( ProjectItem.resource('main.ext', 'src/main-cli.template.ext', model.transpiler) - .asTemplate(model) + .asTemplate(model) ).addToTasks( ProjectItem.resource('build.ext', 'tasks/build.ext', model.transpiler), ProjectItem.resource('build.json', 'tasks/build.json'), diff --git a/lib/commands/new/buildsystems/cli/unit-test-runners/karma.js b/lib/commands/new/buildsystems/cli/unit-test-runners/karma.js index f91e31608..b0266f137 100644 --- a/lib/commands/new/buildsystems/cli/unit-test-runners/karma.js +++ b/lib/commands/new/buildsystems/cli/unit-test-runners/karma.js @@ -11,7 +11,9 @@ module.exports = function(project) { 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('setup.ext', 'test/setup.js', project.model.transpiler), + ProjectItem.resource('app.spec.ext', 'test/unit/app.spec.template.ext', project.model.transpiler) + .asTemplate(project.model) ), ProjectItem.resource('aurelia-karma.js', `test/${project.model.loader.id}.aurelia-karma.js`) ) @@ -23,14 +25,23 @@ module.exports = function(project) { 'karma-sourcemap-loader' ); + if (project.model.features.navigation === 'navigation') { + project.addToContent( + project.tests.add( + project.unitTests.add( + ProjectItem.resource('child-router.spec.ext', 'test/unit/child-router.spec.ext', project.model.transpiler) + .asTemplate(project.model), + ProjectItem.resource('users.spec.ext', 'test/unit/users.spec.ext', project.model.transpiler) + .asTemplate(project.model) + ) + ) + ); + } if (project.model.transpiler.id === 'babel') { project.addToDevDependencies('karma-babel-preprocessor'); } else { project.addToDevDependencies('karma-typescript-preprocessor'); - // prevent duplicate typescript definitions - if (!project.model.unitTestRunners.find(x => x.id === 'jest')) { - project.addToDevDependencies('@types/jasmine'); - } + project.addToDevDependencies('@types/jasmine'); } }; diff --git a/lib/commands/new/buildsystems/general/integration-test-runner/protractor.js b/lib/commands/new/buildsystems/general/integration-test-runner/protractor.js index 593583824..2194a8e2f 100644 --- a/lib/commands/new/buildsystems/general/integration-test-runner/protractor.js +++ b/lib/commands/new/buildsystems/general/integration-test-runner/protractor.js @@ -9,8 +9,7 @@ module.exports = function(project) { 'ts-node' ); - // prevent duplicate typescript definitions - if (!project.model.unitTestRunners.find(x => x.id === 'jest')) { + if (project.model.unitTestRunner.id !== 'jest') { project.addToDevDependencies('@types/jasmine'); } @@ -30,9 +29,12 @@ module.exports = function(project) { ).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('demo.e2e.ext', 'test/e2e/demo.e2e.template.ext', project.model.transpiler) + .asTemplate(project.model), + ProjectItem.resource('skeleton.po.ext', 'test/e2e/skeleton.po.template.ext', project.model.transpiler) + .asTemplate(project.model), + ProjectItem.resource('welcome.po.ext', 'test/e2e/welcome.po.template.ext', project.model.transpiler) + .asTemplate(project.model) ), ProjectItem.resource('protractor.conf.js', configPath) ) diff --git a/lib/commands/new/buildsystems/general/unit-test-runners/jasmine.js b/lib/commands/new/buildsystems/general/unit-test-runners/jasmine.js index e55f64446..1061ce389 100644 --- a/lib/commands/new/buildsystems/general/unit-test-runners/jasmine.js +++ b/lib/commands/new/buildsystems/general/unit-test-runners/jasmine.js @@ -10,10 +10,23 @@ module.exports = function(project) { project.addToContent( project.tests.add( project.unitTests.add( - ProjectItem.resource('app.spec.ext', 'test/unit/app.spec.ext', project.model.transpiler) + ProjectItem.resource('app.spec.ext', 'test/unit/app.spec.template.ext', project.model.transpiler) + .asTemplate(project.model) ) ) ); + if (project.model.features.navigation === 'navigation') { + project.addToContent( + project.tests.add( + project.unitTests.add( + ProjectItem.resource('child-router.spec.ext', 'test/unit/child-router.spec.ext', project.model.transpiler) + .asTemplate(project.model), + ProjectItem.resource('users.spec.ext', 'test/unit/users.spec.ext', project.model.transpiler) + .asTemplate(project.model) + ) + ) + ); + } if (project.model.transpiler.id === 'babel') { project.addToContent( diff --git a/lib/commands/new/buildsystems/webpack/index.js b/lib/commands/new/buildsystems/webpack/index.js index 06c09888c..08a0c01f9 100644 --- a/lib/commands/new/buildsystems/webpack/index.js +++ b/lib/commands/new/buildsystems/webpack/index.js @@ -2,7 +2,7 @@ const ProjectItem = require('../../../../project-item').ProjectItem; -module.exports = function(project, options) { +module.exports = function (project, options) { let model = project.model; const configurePlatform = require('./platforms'); @@ -11,12 +11,10 @@ module.exports = function(project, options) { let configureTranspiler = require(`./transpilers/${model.transpiler.id}`); configureTranspiler(project); - let unitTestRunners = project.model.unitTestRunners; - if (unitTestRunners) { - for (let i = 0; i < unitTestRunners.length; i++) { - let configureUnitTestRunner = require(`./unit-test-runners/${unitTestRunners[i].id}`); - configureUnitTestRunner(project); - } + let unitTestRunner = project.model.unitTestRunner; + if (unitTestRunner) { + let configureUnitTestRunner = require(`./unit-test-runners/${unitTestRunner.id}`); + configureUnitTestRunner(project); } if (model.integrationTestRunner) { @@ -105,7 +103,8 @@ function normalizeForPreprocess(model) { let result = { model: model, - testRunners: arrToObj(model.unitTestRunners) + // testRunners: arrToObj(model.unitTestRunners) + testRunners: arrToObj([model.unitTestRunner]) }; return result; diff --git a/lib/commands/new/buildsystems/webpack/transpilers/babel.js b/lib/commands/new/buildsystems/webpack/transpilers/babel.js index 41a82a6c0..581b14efa 100644 --- a/lib/commands/new/buildsystems/webpack/transpilers/babel.js +++ b/lib/commands/new/buildsystems/webpack/transpilers/babel.js @@ -9,13 +9,12 @@ module.exports = function(project) { 'babel-eslint', 'eslint', 'babel-loader', - '@babel/core', + 'babel-plugin-istanbul', '@babel/plugin-proposal-decorators', '@babel/plugin-proposal-class-properties', '@babel/preset-env', '@babel/core', '@babel/polyfill', - '@babel/register', - 'babel-plugin-istanbul' + '@babel/register' ); }; diff --git a/lib/commands/new/buildsystems/webpack/unit-test-runners/karma.js b/lib/commands/new/buildsystems/webpack/unit-test-runners/karma.js index eb011b466..69cae28b4 100644 --- a/lib/commands/new/buildsystems/webpack/unit-test-runners/karma.js +++ b/lib/commands/new/buildsystems/webpack/unit-test-runners/karma.js @@ -34,9 +34,6 @@ module.exports = function(project) { } else { project.addToDevDependencies('karma-typescript-preprocessor'); - // prevent duplicate typescript definitions - if (!project.model.unitTestRunners.find(x => x.id === 'jest')) { - project.addToDevDependencies('@types/jasmine'); - } + project.addToDevDependencies('@types/jasmine'); } }; diff --git a/lib/commands/new/new-application.json b/lib/commands/new/new-application.json index 6ef746909..34fa3a642 100644 --- a/lib/commands/new/new-application.json +++ b/lib/commands/new/new-application.json @@ -27,13 +27,10 @@ "displayName": "None", "fileExtension": ".json" }, - "unitTestRunners": [{ + "unitTestRunner": { "id": "jest", "displayName": "Jest" - }, { - "id": "karma", - "displayName": "Karma" - }], + }, "testFramework": { "id": "jasmine", "displayName": "Jasmine" @@ -112,7 +109,7 @@ "branches": [ { "case": "default-esnext", - "nextActivity": 950 + "nextActivity": 1000 }, { "case": "default-typescript", @@ -127,7 +124,7 @@ { "type": "state-assign", "id": 500, - "nextActivity": 950, + "nextActivity": 1000, "state": { "transpiler": { "id": "typescript", @@ -229,16 +226,10 @@ "coverage": false } }, - "unitTestRunners": [ - { - "id": "jest", - "displayName": "Jest" - }, - { - "id": "karma", - "displayName": "Karma" - } - ], + "unitTestRunner": { + "id": "jest", + "displayName": "Jest" + }, "testFramework": { "id": "jasmine", "displayName": "Jasmine" @@ -419,10 +410,10 @@ }, { "id": 680, - "type": "input-multiselect", + "type": "input-select", "nextActivity": 681, - "question": "Which unit test runners would you like to use?", - "stateProperty": "unitTestRunners", + "question": "Which unit test runner would you like to use?", + "stateProperty": "unitTestRunner", "options": [ { "displayName": "None", @@ -442,7 +433,7 @@ }, { "displayName": "Jest", - "description": "Configure your app with Jest and Jasmine", + "description": "Configure your app with Jest", "value": { "id": "jest", "displayName": "Jest" @@ -567,27 +558,11 @@ }, { "displayName": "Navigation", - "description": "Add a router and some sample routes. (Also adds Bootstrap and Font Awesome.)", + "description": "Add a router and some sample routes. (Also adds Bootstrap 3 and Font Awesome.)", "value": { "id": "navigation", "displayName": "Navigation" } - }, - { - "displayName": "Bootstrap", - "description": "Install and setup Bootstrap styles and features.", - "value": { - "id": "bootstrap", - "displayName": "Bootstrap" - } - }, - { - "displayName": "Font Awesome", - "description": "Install and setup Font Awesome icons and styles.", - "value": { - "id": "fontAwesome", - "displayName": "Font Awesome" - } } ] }, diff --git a/lib/commands/new/project-template.js b/lib/commands/new/project-template.js index 9b8dc8d60..b0db6f074 100644 --- a/lib/commands/new/project-template.js +++ b/lib/commands/new/project-template.js @@ -324,7 +324,7 @@ exports.ProjectTemplate = class { } addToCopyFiles(files) { - this.model.build.copyFiles = Object.assign({}, this.model.copyFiles, files); + this.model.build.copyFiles = Object.assign({}, this.model.build.copyFiles, files); return this; } diff --git a/lib/dependencies.json b/lib/dependencies.json index 208108aec..7e26af0c5 100644 --- a/lib/dependencies.json +++ b/lib/dependencies.json @@ -21,7 +21,7 @@ "babel-eslint": "^10.0.1", "babel-jest": "^23.6.0", "babel-loader": "^8.0.4", - "babel-plugin-istanbul": "^5.0.1", + "babel-plugin-istanbul": "^5.1.0", "@babel/plugin-proposal-decorators": "^7.1.2", "@babel/plugin-proposal-class-properties": "^7.1.0", "@babel/polyfill": "^7.0.0", diff --git a/lib/resources/content/karma.conf.js b/lib/resources/content/karma.conf.js index 5f942585a..4a839ed00 100644 --- a/lib/resources/content/karma.conf.js +++ b/lib/resources/content/karma.conf.js @@ -1,7 +1,7 @@ 'use strict'; const path = require('path'); const project = require('./aurelia_project/aurelia.json'); -const karmaConfig = project.unitTestRunners.find(x => x.id === 'karma'); +const karmaConfig = project.unitTestRunner; let testSrc = [ { pattern: karmaConfig.source, included: false }, diff --git a/lib/resources/content/karma.conf.ts b/lib/resources/content/karma.conf.ts index e7be6e8ea..ae90591ba 100644 --- a/lib/resources/content/karma.conf.ts +++ b/lib/resources/content/karma.conf.ts @@ -2,7 +2,7 @@ const path = require('path'); const project = require('./aurelia_project/aurelia.json'); const tsconfig = require('./tsconfig.json'); -const karmaConfig = project.unitTestRunners.find(x => x.id === 'karma'); +const karmaConfig = project.unitTestRunner; let testSrc = [ { pattern: karmaConfig.source, included: false }, diff --git a/lib/resources/content/tsconfig.template.json b/lib/resources/content/tsconfig.template.json index 5bf7ab1e3..4cc9f9aa6 100644 --- a/lib/resources/content/tsconfig.template.json +++ b/lib/resources/content/tsconfig.template.json @@ -21,7 +21,7 @@ "emitDecoratorMetadata": true, "experimentalDecorators": true, "moduleResolution": "node", - "sourceRoot": "src", + // "sourceRoot": "src", "sourceMap": true, "allowJs": true, "baseUrl": "src", diff --git a/lib/resources/features/bootstrap.js b/lib/resources/features/bootstrap.js index b901125ac..b39af39ce 100644 --- a/lib/resources/features/bootstrap.js +++ b/lib/resources/features/bootstrap.js @@ -4,21 +4,22 @@ const ProjectItem = require('../../project-item').ProjectItem; module.exports = function (project, model, options) { project.addFeature('jquery', project, model, options); + const baseDir = (model.bundler.id !== 'webpack' ? model.platform.baseDir : 'dist'); project.addToDependencies( 'bootstrap@^3.3.6' ); if (model.bundler.id !== 'webpack') { - project.addToAureliaDependencies( + project.addToCopyFiles( + { + 'node_modules/bootstrap/dist/fonts/*': baseDir + '/bootstrap/fonts' + } + ).addToAureliaDependencies( { 'name': 'bootstrap', - 'path': '../node_modules/bootstrap/dist', - 'main': 'js/bootstrap.min', + 'path': '../node_modules/bootstrap', + 'main': 'dist/js/bootstrap.min', 'deps': [ 'jquery' - ], - 'exports': '$', - 'resources': [ - 'css/bootstrap.css' ] } ); diff --git a/lib/resources/features/fontAwesome.js b/lib/resources/features/fontAwesome.js index 7d6667efb..400c342e0 100644 --- a/lib/resources/features/fontAwesome.js +++ b/lib/resources/features/fontAwesome.js @@ -10,13 +10,7 @@ module.exports = function (project, model, options) { if (model.bundler.id !== 'webpack') { project.addToCopyFiles( { - './node_modules/font-awesome/fonts/**/*.*': baseDir + '/fonts' - } - ).addToAureliaDependencies( - { - 'name': 'font-awesome', - 'path': '../node_modules/font-awesome/css', - 'main': 'font-awesome.css' + 'node_modules/font-awesome/fonts/*': baseDir + '/font-awesome/fonts' } ); } diff --git a/lib/resources/features/jquery.js b/lib/resources/features/jquery.js index 24c432dc8..ebba5bdd0 100644 --- a/lib/resources/features/jquery.js +++ b/lib/resources/features/jquery.js @@ -5,9 +5,9 @@ module.exports = function (project, model, options) { project.addToDependencies( 'jquery@^2.2.4', ); - if (model.bundler.id !== 'webpack') { - project.addToAureliaDependencies( - 'jquery' - ); - } + // if (model.bundler.id !== 'webpack') { + // project.addToAureliaDependencies( + // 'jquery' + // ); + // } }; diff --git a/lib/resources/features/navigation/welcome.js b/lib/resources/features/navigation/welcome.js index 2ddf74551..521ec9bcc 100644 --- a/lib/resources/features/navigation/welcome.js +++ b/lib/resources/features/navigation/welcome.js @@ -17,11 +17,13 @@ export class Welcome { submit() { this.previousValue = this.fullName; + // eslint-disable-next-line no-alert alert(`Welcome, ${this.fullName}!`); } canDeactivate() { if (this.fullName !== this.previousValue) { + // eslint-disable-next-line no-alert return confirm('Are you sure you want to leave?'); } } diff --git a/lib/resources/features/navigation/welcome.ts b/lib/resources/features/navigation/welcome.ts index 2818bc22e..ab2f36ecc 100644 --- a/lib/resources/features/navigation/welcome.ts +++ b/lib/resources/features/navigation/welcome.ts @@ -17,11 +17,13 @@ export class Welcome { public submit() { this.previousValue = this.fullName; + // eslint-disable-next-line no-alert alert(`Welcome, ${this.fullName}!`); } public canDeactivate(): boolean | undefined { if (this.fullName !== this.previousValue) { + // eslint-disable-next-line no-alert return confirm('Are you sure you want to leave?'); } } diff --git a/lib/resources/src/app.template.html b/lib/resources/src/app.template.html index b1195dd92..cd3ec162f 100644 --- a/lib/resources/src/app.template.html +++ b/lib/resources/src/app.template.html @@ -4,10 +4,10 @@

${message}

- + - + @@ -19,4 +19,4 @@

${message}

- \ No newline at end of file + diff --git a/lib/resources/src/app.template.js b/lib/resources/src/app.template.js index bea4c890e..3887b63ad 100644 --- a/lib/resources/src/app.template.js +++ b/lib/resources/src/app.template.js @@ -1,3 +1,7 @@ +// @if bundler.id='webpack' +import {PLATFORM} from 'aurelia-pal'; + +// @endif export class App { // @if features.navigation!='navigation' constructor() { diff --git a/lib/resources/src/main-webpack.template.js b/lib/resources/src/main-webpack.template.js index 1a40eb5b3..9f75187ea 100644 --- a/lib/resources/src/main-webpack.template.js +++ b/lib/resources/src/main-webpack.template.js @@ -11,7 +11,7 @@ import 'bootstrap'; // @endif import environment from './environment'; import {PLATFORM} from 'aurelia-pal'; -import 'babel-polyfill'; +import '@babel/polyfill'; import * as Bluebird from 'bluebird'; // remove out if you don't want a Promise polyfill (remove also from webpack.config.js) diff --git a/lib/resources/test/e2e/demo.e2e.template.js b/lib/resources/test/e2e/demo.e2e.template.js new file mode 100644 index 000000000..0b11ebb27 --- /dev/null +++ b/lib/resources/test/e2e/demo.e2e.template.js @@ -0,0 +1,54 @@ +import {PageObjectWelcome} from './welcome.po'; +import {PageObjectSkeleton} from './skeleton.po'; +import {config} from '../protractor.conf'; + +describe('aurelia skeleton app', function() { + let poWelcome; + let poSkeleton; + + beforeEach(async () => { + poSkeleton = new PageObjectSkeleton(); + poWelcome = new PageObjectWelcome(); + + await browser.loadAndWaitForAureliaPage(`http://localhost:${config.port}`); + }); + + it('should load the page and display the initial page title', async () => { + await expect(await poSkeleton.getCurrentPageTitle()).toContain('Aurelia'); + }); + +// @if features.navigation!='navigation' + it('should display greeting', async () => { + await expect(await poWelcome.getGreeting()).toBe('Hello World!'); + }); +// @endif + +// @if features.navigation='navigation' +it('should display greeting', async () => { + await expect(await poWelcome.getGreeting()).toBe('Welcome to the Aurelia Navigation App!'); +}); + +it('should automatically write down the fullname', async () => { + await poWelcome.setFirstname('Jane'); + await poWelcome.setLastname('Doe'); + + // binding is not synchronous, + // therefore we should wait some time until the binding is updated + await browser.wait( + ExpectedConditions.textToBePresentInElement( + poWelcome.getFullnameElement(), 'JANE DOE' + ), 200 + ); +}); + +it('should show alert message when clicking submit button', async () => { + await expect(await poWelcome.openAlertDialog()).toBe(true); +}); + +it('should navigate to users page', async () => { + await poSkeleton.navigateTo('#/users'); + browser.sleep(200); + await expect(await poSkeleton.getCurrentPageTitle()).toBe('Github Users | Aurelia'); +}); +// @endif +}); diff --git a/lib/resources/test/e2e/demo.e2e.template.ts b/lib/resources/test/e2e/demo.e2e.template.ts new file mode 100644 index 000000000..90464bdd5 --- /dev/null +++ b/lib/resources/test/e2e/demo.e2e.template.ts @@ -0,0 +1,55 @@ +import {PageObjectWelcome} from './welcome.po'; +import {PageObjectSkeleton} from './skeleton.po'; +import {browser, element, by, By, $, $$, ExpectedConditions} from 'aurelia-protractor-plugin/protractor'; +import {config} from '../protractor.conf'; + +describe('aurelia skeleton app', function() { + let poWelcome: PageObjectWelcome; + let poSkeleton: PageObjectSkeleton; + + beforeEach(async () => { + poSkeleton = new PageObjectSkeleton(); + poWelcome = new PageObjectWelcome(); + + await browser.loadAndWaitForAureliaPage(`http://localhost:${config.port}`); + }); + + it('should load the page and display the initial page title', async () => { + await expect(await poSkeleton.getCurrentPageTitle()).toContain('Aurelia'); + }); + +// @if features.navigation!='navigation' +it('should display greeting', async () => { + await expect(await poWelcome.getGreeting()).toBe('Hello World!'); + }); +// @endif + +// @if features.navigation='navigation' + it('should display greeting', async () => { + await expect(await poWelcome.getGreeting()).toBe('Welcome to the Aurelia Navigation App!'); + }); + + it('should automatically write down the fullname', async () => { + await poWelcome.setFirstname('Jane'); + await poWelcome.setLastname('Doe'); + + // binding is not synchronous, + // therefore we should wait some time until the binding is updated + await browser.wait( + ExpectedConditions.textToBePresentInElement( + poWelcome.getFullnameElement(), 'JANE DOE' + ), 200 + ); + }); + + it('should show alert message when clicking submit button', async () => { + await expect(await poWelcome.openAlertDialog()).toBe(true); + }); + + it('should navigate to users page', async () => { + await poSkeleton.navigateTo('#/users'); + browser.sleep(200); + await expect(await poSkeleton.getCurrentPageTitle()).toBe('Github Users | Aurelia'); + }); +// @endif +}); diff --git a/lib/resources/test/e2e/demo.e2e.ts b/lib/resources/test/e2e/demo.e2e.ts index 49b23dad0..9f67d922d 100644 --- a/lib/resources/test/e2e/demo.e2e.ts +++ b/lib/resources/test/e2e/demo.e2e.ts @@ -1,15 +1,15 @@ -import {PageObject_Welcome} from './welcome.po'; -import {PageObject_Skeleton} from './skeleton.po'; +import {PageObjectWelcome} from './welcome.po'; +import {PageObjectSkeleton} from './skeleton.po'; import {browser, element, by, By, $, $$, ExpectedConditions} from 'aurelia-protractor-plugin/protractor'; import {config} from '../protractor.conf'; describe('aurelia skeleton app', function() { - let poWelcome: PageObject_Welcome; - let poSkeleton: PageObject_Skeleton; + let poWelcome: PageObjectWelcome; + let poSkeleton: PageObjectSkeleton; beforeEach(async () => { - poSkeleton = new PageObject_Skeleton(); - poWelcome = new PageObject_Welcome(); + poSkeleton = new PageObjectSkeleton(); + poWelcome = new PageObjectWelcome(); await browser.loadAndWaitForAureliaPage(`http://localhost:${config.port}`); }); diff --git a/lib/resources/test/e2e/skeleton.po.template.js b/lib/resources/test/e2e/skeleton.po.template.js new file mode 100644 index 000000000..78181eedb --- /dev/null +++ b/lib/resources/test/e2e/skeleton.po.template.js @@ -0,0 +1,13 @@ +export class PageObjectSkeleton { + getCurrentPageTitle() { + return browser.getTitle(); + } + +// @if features.navigation='navigation' + async navigateTo(href) { + const navigatingReady = browser.waitForRouterComplete(); + await element(by.css('a[href="' + href + '"]')).click(); + await navigatingReady; + } +// @endif +} diff --git a/lib/resources/test/e2e/skeleton.po.template.ts b/lib/resources/test/e2e/skeleton.po.template.ts new file mode 100644 index 000000000..cbe340b3b --- /dev/null +++ b/lib/resources/test/e2e/skeleton.po.template.ts @@ -0,0 +1,15 @@ +import {browser, element, by, By, $, $$, ExpectedConditions} from 'aurelia-protractor-plugin/protractor'; + +export class PageObjectSkeleton { + getCurrentPageTitle() { + return browser.getTitle(); + } + +// @if features.navigation='navigation' + async navigateTo(href) { + const navigatingReady = browser.waitForRouterComplete(); + await element(by.css('a[href="' + href + '"]')).click(); + await navigatingReady; + } +// @endif +} diff --git a/lib/resources/test/e2e/skeleton.po.ts b/lib/resources/test/e2e/skeleton.po.ts index c4a130818..024f69a1b 100644 --- a/lib/resources/test/e2e/skeleton.po.ts +++ b/lib/resources/test/e2e/skeleton.po.ts @@ -1,6 +1,6 @@ import {browser, element, by, By, $, $$, ExpectedConditions} from 'aurelia-protractor-plugin/protractor'; -export class PageObject_Skeleton { +export class PageObjectSkeleton { getCurrentPageTitle() { return browser.getTitle(); } diff --git a/lib/resources/test/e2e/welcome.po.template.js b/lib/resources/test/e2e/welcome.po.template.js new file mode 100644 index 000000000..20ee217a2 --- /dev/null +++ b/lib/resources/test/e2e/welcome.po.template.js @@ -0,0 +1,46 @@ +export class PageObjectWelcome { +// @if features.navigation!='navigation' + getGreeting() { + return element(by.tagName('h1')).getText(); + } +// @endif + +// @if features.navigation='navigation' + getGreeting() { + return element(by.tagName('h2')).getText(); + } + + setFirstname(value) { + return element(by.valueBind('firstName')).clear().sendKeys(value); + } + + setLastname(value) { + return element(by.valueBind('lastName')).clear().sendKeys(value); + } + + getFullnameElement() { + return element(by.css('.help-block')); + } + + getFullname() { + return this.getFullnameElement().getText(); + } + + pressSubmitButton() { + return element(by.css('button[type="submit"]')).click(); + } + + async openAlertDialog() { + await this.pressSubmitButton(); + + await browser.wait(ExpectedConditions.alertIsPresent(), 5000); + + try { + await browser.switchTo().alert().accept(); + return true; + } catch (e) { + return false; + } + } +// @endif +} diff --git a/lib/resources/test/e2e/welcome.po.template.ts b/lib/resources/test/e2e/welcome.po.template.ts new file mode 100644 index 000000000..b95327c03 --- /dev/null +++ b/lib/resources/test/e2e/welcome.po.template.ts @@ -0,0 +1,50 @@ +import {browser, element, by, By, $, $$, ExpectedConditions} from 'aurelia-protractor-plugin/protractor'; + +export class PageObjectWelcome { +// @if features.navigation!='navigation' + getGreeting() { + return element(by.tagName('h1')).getText(); + } +// @endif + +// @if features.navigation='navigation' + getGreeting() { + return element(by.tagName('h2')).getText(); + } + + setFirstname(value) { + let firstName = element(by.valueBind('firstName')); + return firstName.clear().then(() => firstName.sendKeys(value)); + } + + setLastname(value) { + let lastName = element(by.valueBind('lastName')); + return lastName.clear().then(() => lastName.sendKeys(value)); + } + + getFullnameElement() { + return element(by.css('.help-block')); + } + + getFullname() { + return this.getFullnameElement().getText(); + } + + pressSubmitButton() { + return element(by.css('button[type="submit"]')).click(); + } + + async openAlertDialog() { + await this.pressSubmitButton(); + + await browser.wait(ExpectedConditions.alertIsPresent(), 5000); + + try { + await browser.switchTo().alert().accept(); + return true; + } catch (e) { + return false; + } + } +// @endif +} diff --git a/lib/resources/test/e2e/welcome.po.ts b/lib/resources/test/e2e/welcome.po.ts index a146e106e..891a2e820 100644 --- a/lib/resources/test/e2e/welcome.po.ts +++ b/lib/resources/test/e2e/welcome.po.ts @@ -1,6 +1,6 @@ import {browser, element, by, By, $, $$, ExpectedConditions} from 'aurelia-protractor-plugin/protractor'; -export class PageObject_Welcome { +export class PageObjectWelcome { getGreeting() { return element(by.tagName('h1')).getText(); } diff --git a/lib/resources/test/unit/app.spec.template.js b/lib/resources/test/unit/app.spec.template.js new file mode 100644 index 000000000..f13af4024 --- /dev/null +++ b/lib/resources/test/unit/app.spec.template.js @@ -0,0 +1,52 @@ +import {App} from '../../src/app'; + +// @if features.navigation!='navigation' +describe('the app', () => { + it('says hello', () => { + expect(new App().message).toBe('Hello World!'); + }); +}); +// @endif + +// @if features.navigation='navigation' +class RouterStub { + configure(handler) { + handler(this); + } + + map(routes) { + this.routes = routes; + } +} + +describe('the App module', () => { + var sut; + var mockedRouter; + + beforeEach(() => { + mockedRouter = new RouterStub(); + sut = new App(); + sut.configureRouter(mockedRouter, mockedRouter); + }); + + it('contains a router property', () => { + expect(sut.router).toBeDefined(); + }); + + it('configures the router title', () => { + expect(sut.router.title).toEqual('Aurelia'); + }); + + it('should have a welcome route', () => { + expect(sut.router.routes).toContain/* @if unitTestRunner.id='jest' **Equal/* @endif */({ route: ['', 'welcome'], name: 'welcome', moduleId: 'welcome', nav: true, title: 'Welcome' }); + }); + + it('should have a users route', () => { + expect(sut.router.routes).toContain/* @if unitTestRunner.id='jest' **Equal/* @endif */({ route: 'users', name: 'users', moduleId: 'users', nav: true, title: 'Github Users' }); + }); + + it('should have a child router route', () => { + expect(sut.router.routes).toContain/* @if unitTestRunner.id='jest' **Equal/* @endif */({ route: 'child-router', name: 'child-router', moduleId: 'child-router', nav: true, title: 'Child Router' }); + }); +}); +// @endif diff --git a/lib/resources/test/unit/app.spec.template.ts b/lib/resources/test/unit/app.spec.template.ts new file mode 100644 index 000000000..43dce5a9e --- /dev/null +++ b/lib/resources/test/unit/app.spec.template.ts @@ -0,0 +1,53 @@ +import {App} from '../../src/app'; + +// @if features.navigation!='navigation' +describe('the app', () => { + it('says hello', () => { + expect(new App().message).toBe('Hello World!'); + }); +}); +// @endif + +// @if features.navigation='navigation' +class RouterStub { + routes; + + configure(handler) { + handler(this); + } + + map(routes) { + this.routes = routes; + } +} + +describe('the App module', () => { + var sut, mockedRouter; + + beforeEach(() => { + mockedRouter = new RouterStub(); + sut = new App(); + sut.configureRouter(mockedRouter, mockedRouter); + }); + + it('contains a router property', () => { + expect(sut.router).toBeDefined(); + }); + + it('configures the router title', () => { + expect(sut.router.title).toEqual('Aurelia'); + }); + + it('should have a welcome route', () => { + expect(sut.router.routes).toContain/* @if unitTestRunner.id='jest' **Equal/* @endif */({ route: ['','welcome'], name: 'welcome', moduleId: 'welcome', nav: true, title:'Welcome' }); + }); + + it('should have a users route', () => { + expect(sut.router.routes).toContain/* @if unitTestRunner.id='jest' **Equal/* @endif */({ route: 'users', name: 'users', moduleId: 'users', nav: true, title:'Github Users' }); + }); + + it('should have a child router route', () => { + expect(sut.router.routes).toContain/* @if unitTestRunner.id='jest' **Equal/* @endif */({ route: 'child-router', name: 'child-router', moduleId: 'child-router', nav: true, title:'Child Router' }); + }); +}); +// @endif diff --git a/lib/resources/test/unit/child-router.spec.js b/lib/resources/test/unit/child-router.spec.js new file mode 100644 index 000000000..d0619a9bf --- /dev/null +++ b/lib/resources/test/unit/child-router.spec.js @@ -0,0 +1,42 @@ +import {ChildRouter} from '../../src/child-router'; + +class RouterStub { + configure(handler) { + handler(this); + } + + map(routes) { + this.routes = routes; + } +} + +describe('the Child Router module', () => { + var sut; + var mockedRouter; + + beforeEach(() => { + mockedRouter = new RouterStub(); + sut = new ChildRouter(); + sut.configureRouter(mockedRouter, mockedRouter); + }); + + it('contains a router property', () => { + expect(sut.router).toBeDefined(); + }); + + it('configures the heading', () => { + expect(sut.heading).toEqual('Child Router'); + }); + + it('should have a welcome route', () => { + expect(sut.router.routes).toContain/* @if unitTestRunner.id='jest' **Equal/* @endif */({ route: ['', 'welcome'], name: 'welcome', moduleId: '/* @if bundler.id='webpack' **.//* @endif */welcome', nav: true, title: 'Welcome' }); + }); + + it('should have a users route', () => { + expect(sut.router.routes).toContain/* @if unitTestRunner.id='jest' **Equal/* @endif */({ route: 'users', name: 'users', moduleId: '/* @if bundler.id='webpack' **.//* @endif */users', nav: true, title: 'Github Users' }); + }); + + it('should have a child router route', () => { + expect(sut.router.routes).toContain/* @if unitTestRunner.id='jest' **Equal/* @endif */({ route: 'child-router', name: 'child-router', moduleId: '/* @if bundler.id='webpack' **.//* @endif */child-router', nav: true, title: 'Child Router' }); + }); +}); diff --git a/lib/resources/test/unit/child-router.spec.ts b/lib/resources/test/unit/child-router.spec.ts new file mode 100644 index 000000000..95449ce8a --- /dev/null +++ b/lib/resources/test/unit/child-router.spec.ts @@ -0,0 +1,42 @@ +import {ChildRouter} from '../../src/child-router'; + +class RouterStub { + routes; + + configure(handler) { + handler(this); + } + map(routes) { + this.routes = routes; + } +} + +describe('the Child Router module', () => { + var sut, mockedRouter; + + beforeEach(() => { + mockedRouter = new RouterStub(); + sut = new ChildRouter(); + sut.configureRouter(mockedRouter, mockedRouter); + }); + + it('contains a router property', () => { + expect(sut.router).toBeDefined(); + }); + + it('configures the heading', () => { + expect(sut.heading).toEqual('Child Router'); + }); + + it('should have a welcome route', () => { + expect(sut.router.routes).toContain/* @if unitTestRunner.id='jest' **Equal/* @endif */({ route: ['','welcome'], name: 'welcome', moduleId: '/* @if bundler.id='webpack' **.//* @endif */welcome', nav: true, title:'Welcome' }); + }); + + it('should have a users route', () => { + expect(sut.router.routes).toContain/* @if unitTestRunner.id='jest' **Equal/* @endif */({ route: 'users', name: 'users', moduleId: '/* @if bundler.id='webpack' **.//* @endif */users', nav: true, title:'Github Users' }); + }); + + it('should have a child router route', () => { + expect(sut.router.routes).toContain/* @if unitTestRunner.id='jest' **Equal/* @endif */({ route: 'child-router', name: 'child-router', moduleId: '/* @if bundler.id='webpack' **.//* @endif */child-router', nav: true, title:'Child Router' }); + }); +}); diff --git a/lib/resources/test/unit/users.spec.js b/lib/resources/test/unit/users.spec.js new file mode 100644 index 000000000..5b557045f --- /dev/null +++ b/lib/resources/test/unit/users.spec.js @@ -0,0 +1,30 @@ +import {Users} from '../../src/users'; + +class HttpStub { + fetch(url) { + var response = this.itemStub; + this.url = url; + return new Promise((resolve) => { + resolve({ json: () => response }); + }); + } + + configure(func) { + } +} + +describe('the Users module', () => { + it('sets fetch response to users', (done) => { + var http = new HttpStub(); + var sut = new Users(http); + var itemStubs = [1]; + var itemFake = [2]; + + http.itemStub = itemStubs; + sut.activate().then(() => { + expect(sut.users).toBe(itemStubs); + expect(sut.users).not.toBe(itemFake); + done(); + }); + }); +}); diff --git a/lib/resources/test/unit/users.spec.ts b/lib/resources/test/unit/users.spec.ts new file mode 100644 index 000000000..070253030 --- /dev/null +++ b/lib/resources/test/unit/users.spec.ts @@ -0,0 +1,36 @@ +import {Users} from '../../src/users'; +import {HttpClient} from 'aurelia-fetch-client'; + +class HttpStub { + items: any[]; + + fetch(url) { + return new Promise(resolve => { + resolve({ json: () => this.items }); + }); + } + + configure(func) { } +} + +function createHttpStub(): any { + return new HttpStub(); +} + +describe('the Users module', () => { + + it('sets fetch response to users', (done) => { + var http = createHttpStub(), + sut = new Users(http), + itemStubs = [1], + itemFake = [2]; + + http.items = itemStubs; + + sut.activate().then(() => { + expect(sut.users).toBe(itemStubs); + expect(sut.users).not.toBe(itemFake); + done(); + }); + }); +}); diff --git a/lib/resources/test/webpack/babel/karma-bundle.js b/lib/resources/test/webpack/babel/karma-bundle.js index 91baa8ff6..ddbec218e 100644 --- a/lib/resources/test/webpack/babel/karma-bundle.js +++ b/lib/resources/test/webpack/babel/karma-bundle.js @@ -5,10 +5,6 @@ import {install as installJasmineAsync} from 'jest-jasmine2/jasmine_async'; // enable running Promise-returning tests: installJasmineAsync(global); -// enable running the same unit tests by using the Jest expect: -installJestExpect(); -global.jest = false; - // disable stacktrace limit so we do not loose any error information Error.stackTraceLimit = Infinity; @@ -45,36 +41,3 @@ function runTests(contexts) { function requireAllInContext(requireContext) { return requireContext.keys().map(requireContext); } - -/** - * A non-snapshot version of jest-jasmine2/jest-expect - * See https://github.com/facebook/jest/blob/master/packages/jest-jasmine2/src/jest-expect.js - */ -function installJestExpect() { - const expect = require('jest-matchers'); - global.expect = expect; - - const jasmine = global.jasmine; - jasmine.anything = expect.anything; - jasmine.any = expect.any; - jasmine.objectContaining = expect.objectContaining; - jasmine.arrayContaining = expect.arrayContaining; - jasmine.stringMatching = expect.stringMatching; - jasmine.addMatchers = (jasmineMatchersObject) => { - const jestMatchersObject = Object.create(null); - Object.keys(jasmineMatchersObject).forEach(name => { - jestMatchersObject[name] = function() { - const result = jasmineMatchersObject[name](jasmine.matchersUtil, null); - // if there is no 'negativeCompare', both should be handled by `compare` - const negativeCompare = result.negativeCompare || result.compare; - - return this.isNot - ? negativeCompare.apply(null, arguments) - : result.compare.apply(null, arguments); - }; - }); - - const expect = global.expect; - expect.extend(jestMatchersObject); - }; -} \ No newline at end of file diff --git a/lib/resources/test/webpack/typescript/karma-bundle.js b/lib/resources/test/webpack/typescript/karma-bundle.js index 91baa8ff6..ddbec218e 100644 --- a/lib/resources/test/webpack/typescript/karma-bundle.js +++ b/lib/resources/test/webpack/typescript/karma-bundle.js @@ -5,10 +5,6 @@ import {install as installJasmineAsync} from 'jest-jasmine2/jasmine_async'; // enable running Promise-returning tests: installJasmineAsync(global); -// enable running the same unit tests by using the Jest expect: -installJestExpect(); -global.jest = false; - // disable stacktrace limit so we do not loose any error information Error.stackTraceLimit = Infinity; @@ -45,36 +41,3 @@ function runTests(contexts) { function requireAllInContext(requireContext) { return requireContext.keys().map(requireContext); } - -/** - * A non-snapshot version of jest-jasmine2/jest-expect - * See https://github.com/facebook/jest/blob/master/packages/jest-jasmine2/src/jest-expect.js - */ -function installJestExpect() { - const expect = require('jest-matchers'); - global.expect = expect; - - const jasmine = global.jasmine; - jasmine.anything = expect.anything; - jasmine.any = expect.any; - jasmine.objectContaining = expect.objectContaining; - jasmine.arrayContaining = expect.arrayContaining; - jasmine.stringMatching = expect.stringMatching; - jasmine.addMatchers = (jasmineMatchersObject) => { - const jestMatchersObject = Object.create(null); - Object.keys(jasmineMatchersObject).forEach(name => { - jestMatchersObject[name] = function() { - const result = jasmineMatchersObject[name](jasmine.matchersUtil, null); - // if there is no 'negativeCompare', both should be handled by `compare` - const negativeCompare = result.negativeCompare || result.compare; - - return this.isNot - ? negativeCompare.apply(null, arguments) - : result.compare.apply(null, arguments); - }; - }); - - const expect = global.expect; - expect.extend(jestMatchersObject); - }; -} \ No newline at end of file diff --git a/lib/workflow/activities/project-create.js b/lib/workflow/activities/project-create.js index efcc4ee95..91017925d 100644 --- a/lib/workflow/activities/project-create.js +++ b/lib/workflow/activities/project-create.js @@ -32,8 +32,8 @@ module.exports = class { features: {} }; - if (context.state.unitTestRunners) { - model.unitTestRunners = context.state.unitTestRunners; + if (context.state.unitTestRunner) { + model.unitTestRunner = context.state.unitTestRunner; } if (context.state.integrationTestRunner) { @@ -99,10 +99,8 @@ module.exports = class { text += ` Markup Processor: ${model.markupProcessor.displayName}` + os.EOL; text += ` CSS Processor: ${model.cssProcessor.displayName}` + os.EOL; - if (model.unitTestRunners) { - for (let i = 0; i < model.unitTestRunners.length; i++) { - text += ` Unit Test Runner: ${model.unitTestRunners[i].displayName}` + os.EOL; - } + if (model.unitTestRunner) { + text += ` Unit Test Runner: ${model.unitTestRunner.displayName}` + os.EOL; } if (model.integrationTestRunner) { diff --git a/package-lock.json b/package-lock.json index b9627d0a9..a877382c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -295,7 +295,7 @@ "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "integrity": "sha1-+PLIh60Qv2f2NPAFtph/7TF5qsg=", "dev": true }, "acorn": { @@ -361,7 +361,7 @@ "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "integrity": "sha1-q5Pyeo3BPSjKyBXEYhQ6bZASrp4=", "dev": true, "requires": { "is-fullwidth-code-point": "^2.0.0", @@ -659,7 +659,7 @@ "async-limiter": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", - "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==", + "integrity": "sha1-ePrtjD0HSrgfIrTphdeehzj3IPg=", "dev": true }, "async-settle": { @@ -823,7 +823,7 @@ "boxen": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/boxen/-/boxen-1.3.0.tgz", - "integrity": "sha512-TNPjfTr432qx7yOjQyaXm3dSR0MH9vXp7eT1BFSl/C51g+EFnOR9hTg1IreahGBmDNCehscshe45f+C1TBZbLw==", + "integrity": "sha1-VcbDmouljZxhrSLNh3Uy3rZlogs=", "dev": true, "requires": { "ansi-align": "^2.0.0", @@ -856,7 +856,7 @@ "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "integrity": "sha1-q5Pyeo3BPSjKyBXEYhQ6bZASrp4=", "dev": true, "requires": { "is-fullwidth-code-point": "^2.0.0", @@ -1187,7 +1187,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", + "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", "dev": true }, "class-utils": { @@ -1389,7 +1389,7 @@ "dot-prop": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.0.tgz", - "integrity": "sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ==", + "integrity": "sha1-HxngwuGqDjJ5fEl5nyg3rGr2nFc=", "dev": true, "requires": { "is-obj": "^1.0.0" @@ -2207,7 +2207,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", "dev": true, "requires": { "esutils": "^2.0.2" @@ -4232,7 +4232,7 @@ "https-proxy-agent": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz", - "integrity": "sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==", + "integrity": "sha1-UVUpcPoE1yPgTFbQQXjD+SWSu8A=", "dev": true, "requires": { "agent-base": "^4.1.0", @@ -4738,7 +4738,7 @@ "jasmine-spec-reporter": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/jasmine-spec-reporter/-/jasmine-spec-reporter-4.2.1.tgz", - "integrity": "sha512-FZBoZu7VE5nR7Nilzy+Np8KuVIOxF4oXDPDknehCYBDE080EnlPu0afdZNmpGDBRCUBv3mj5qgqCRmk6W/K8vg==", + "integrity": "sha1-HWMq7ANBZwrTJPkrqEtLMrNeniI=", "dev": true, "requires": { "colors": "1.1.2" @@ -6764,7 +6764,7 @@ "split": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", - "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", + "integrity": "sha1-YFvZvjA6pZ+zX5Ip++oN3snqB9k=", "dev": true, "requires": { "through": "2" @@ -6781,7 +6781,7 @@ "split2": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/split2/-/split2-2.2.0.tgz", - "integrity": "sha512-RAb22TG39LhI31MbreBgIuKiIKhVsawfTgEGqKHTK87aG+ul/PB8Sqoi3I7kVdRWiCfrKxK3uo4/YUkpNvhPbw==", + "integrity": "sha1-GGsldbz4PoW30YRldWI47k7kJJM=", "dev": true, "requires": { "through2": "^2.0.2" @@ -6953,7 +6953,7 @@ "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "integrity": "sha1-q5Pyeo3BPSjKyBXEYhQ6bZASrp4=", "dev": true, "requires": { "is-fullwidth-code-point": "^2.0.0", @@ -7134,7 +7134,7 @@ "touch": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", - "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", + "integrity": "sha1-/jZfX3XsntTlaCXgu3bSSrdK+Ds=", "dev": true, "requires": { "nopt": "~1.0.10" @@ -7627,7 +7627,7 @@ "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "integrity": "sha1-q5Pyeo3BPSjKyBXEYhQ6bZASrp4=", "dev": true, "requires": { "is-fullwidth-code-point": "^2.0.0", @@ -7677,7 +7677,7 @@ "write-file-atomic": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.3.0.tgz", - "integrity": "sha512-xuPeK4OdjWqtfi59ylvVL0Yn35SF3zgcAcv7rBPFHVaEapaDr4GdGgm3j7ckTwH9wHL7fGmgfAnb0+THrHb8tA==", + "integrity": "sha1-H/YVdcLipOjlENb6TiQ8zhg5mas=", "dev": true, "requires": { "graceful-fs": "^4.1.11", diff --git a/spec/lib/workflow/state-assign.spec.js b/spec/lib/workflow/state-assign.spec.js index 51e4757e1..a96c64fcc 100644 --- a/spec/lib/workflow/state-assign.spec.js +++ b/spec/lib/workflow/state-assign.spec.js @@ -12,7 +12,7 @@ describe('The StateAssign module', () => { nextActivity: 15, state: { name: 'my-app', - unitTestRunners: ['karma', 'jest'] + unitTestRunner: 'jest' } }); let next = jasmine.createSpy('next'); @@ -24,7 +24,7 @@ describe('The StateAssign module', () => { sut.execute.call(stateassign, context); expect(context.state.name).toBe('my-app'); - expect(context.state.unitTestRunners).toEqual(['karma', 'jest']); + expect(context.state.unitTestRunner).toEqual('jest'); expect(next).toHaveBeenCalledWith(15); }); });