diff --git a/package.json b/package.json index 6506870e630f..5cea0f557666 100644 --- a/package.json +++ b/package.json @@ -53,11 +53,13 @@ "devDependencies": { "broccoli-stew": "^0.3.6", "chai": "^3.2.0", + "cucumber": "^0.9.2", "exists-sync": "0.0.3", "glob": "^5.0.14", "minimatch": "^2.0.10", "mocha": "^2.2.5", "rewire": "^2.3.4", + "shelljs": "^0.5.3", "through": "^2.3.8", "walk-sync": "^0.1.3" } diff --git a/tests/e2e/basic.feature b/tests/e2e/basic.feature new file mode 100644 index 000000000000..183441d943fd --- /dev/null +++ b/tests/e2e/basic.feature @@ -0,0 +1,58 @@ +Feature: Basic Workflow + As a user + I want to be able to install the tool, generate a project, build it, test it, + generate a component, generate a service, generate a pipe and test it again + + Scenario: Generate new project + Given the name "test-project" + When I create a new project + Then it creates the files: + """ + ember-cli-build.js + .gitignore + karma-test-shim.js + karma.conf.js + package.json + src/app/test-project.html + src/app/test-project.spec.ts + src/app/test-project.ts + src/app.ts + src/favicon.ico + src/index.html + src/tsconfig.json + """ + Then it initializes a git repository + Then it install npm dependencies + + Scenario: Build new project + Given the directory "test-project" + When I build the project + Then it creates the files: + """ + """ + + Scenario: Run tests for new project + Given the directory "test-project" + When I run the tests + Then it passes with: + """ + .. + Chrome + """ + + Scenario: Generate a component + Given the directory "test-project" + And the name "test-component" + When I generate a component + Then it creates the files: + """ + """ + + Scenario: Run tests for a project with a generated component + Given the directory "test-project" + When I run the tests + Then it passes with: + """ + ... + Chrome + """ \ No newline at end of file diff --git a/tests/e2e/steps/basic.steps.js b/tests/e2e/steps/basic.steps.js new file mode 100644 index 000000000000..c7b2293e7a31 --- /dev/null +++ b/tests/e2e/steps/basic.steps.js @@ -0,0 +1,63 @@ +var chai = require('chai'); +var shell = require('shelljs'); + +var chaiAsPromised = require('chai-as-promised'); +chai.use(chaiAsPromised); + +var expect = chai.expect; + +module.exports = function() { + var _name; + var _newOutput; + + this.Given(/^the name "([^"]*)"$/, function(name, cb) { + _name = name; + cb(); + }); + + this.Given(/^the directory "([^"]*)"$/, function(directory, cb) { + cb(); + }); + + this.When(/^I create a new project$/, function(cb) { + _newOutput = shell.exec('ng new ' + _name + ' --skip-npm --skip-git', {silent: true}).output; + cb(); + }); + + this.When(/^I build the project$/, function(cb) { + cb(); + }); + + this.When(/^I run the tests$/, function(cb) { + cb(); + }); + + this.When(/^I generate a component$/, function(cb) { + cb(); + }); + + this.Then(/^it initializes a git repository$/, function(cb) { + cb(); + }); + + this.Then(/^it install npm dependencies$/, function(cb) { + cb(); + }); + + this.Then(/^it creates the files:$/, function(files, cb) { + var patternToCatch = /create\s(.*)/gm; + var patternToReplace = /create\s/gm; + var caught = _newOutput.match(patternToCatch); + var _files = files.split(/\s/); + + caught.forEach(function(item, index) { + expect(item.replace(patternToReplace, '')).to.equal(_files[index]); + }); + + cb(); + }); + + this.Then(/^it passes with:$/, function(string, cb) { + cb(); + }); +}; \ No newline at end of file