Skip to content

WIP tests: add basic e2e tests #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
58 changes: 58 additions & 0 deletions tests/e2e/basic.feature
Original file line number Diff line number Diff line change
@@ -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
"""
63 changes: 63 additions & 0 deletions tests/e2e/steps/basic.steps.js
Original file line number Diff line number Diff line change
@@ -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();
});
};