Skip to content

Commit cf7c597

Browse files
committed
tests: add basic e2e tests
1 parent ba4f81b commit cf7c597

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@
5353
"devDependencies": {
5454
"broccoli-stew": "^0.3.6",
5555
"chai": "^3.2.0",
56+
"cucumber": "^0.9.2",
5657
"exists-sync": "0.0.3",
5758
"glob": "^5.0.14",
5859
"minimatch": "^2.0.10",
5960
"mocha": "^2.2.5",
6061
"rewire": "^2.3.4",
62+
"shelljs": "^0.5.3",
6163
"through": "^2.3.8",
6264
"walk-sync": "^0.1.3"
6365
}

tests/e2e/basic.feature

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Feature: Basic Workflow
2+
As a user
3+
I want to be able to install the tool, generate a project, build it, test it,
4+
generate a component, generate a service, generate a pipe and test it again
5+
6+
Scenario: Generate new project
7+
Given the name "test-project"
8+
When I create a new project
9+
Then it creates the files:
10+
"""
11+
"""
12+
Then it initializes a git repository
13+
Then it install npm dependencies
14+
15+
Scenario: Build new project
16+
Given the directory "test-project"
17+
When I build the project
18+
Then it creates the files:
19+
"""
20+
"""
21+
22+
Scenario: Run tests for new project
23+
Given the directory "test-project"
24+
When I run the tests
25+
Then it passes with:
26+
"""
27+
..
28+
Chrome
29+
"""
30+
31+
Scenario: Generate a component
32+
Given the directory "test-project"
33+
And the name "test-component"
34+
When I generate a component
35+
Then it creates the files:
36+
"""
37+
"""
38+
39+
Scenario: Run tests for a project with a generated component
40+
Given the directory "test-project"
41+
When I run the tests
42+
Then it passes with:
43+
"""
44+
...
45+
Chrome
46+
"""

tests/e2e/steps/basic.steps.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
var chai = require('chai');
2+
var shell = require('shelljs');
3+
4+
var chaiAsPromised = require('chai-as-promised');
5+
chai.use(chaiAsPromised);
6+
7+
var expect = chai.expect;
8+
9+
module.exports = function() {
10+
this.Given(/^the name "([^"]*)"$/, function(name, cb) {
11+
shell.exec('ng new ' + name + ' --skip-npm --skip-git');
12+
cb();
13+
});
14+
15+
this.Given(/^the directory "([^"]*)"$/, function(directory, cb) {
16+
shell.cd(directory);
17+
cb();
18+
});
19+
20+
this.When(/^I create a new project$/, function(cb) {
21+
// Write code here that turns the phrase above into concrete actions
22+
cb();
23+
});
24+
25+
this.When(/^I build the project$/, function(cb) {
26+
// Write code here that turns the phrase above into concrete actions
27+
cb();
28+
});
29+
30+
this.When(/^I run the tests$/, function(cb) {
31+
// Write code here that turns the phrase above into concrete actions
32+
cb();
33+
});
34+
35+
this.When(/^I generate a component$/, function(cb) {
36+
// Write code here that turns the phrase above into concrete actions
37+
cb();
38+
});
39+
40+
this.Then(/^it initializes a git repository$/, function(cb) {
41+
// Write code here that turns the phrase above into concrete actions
42+
cb();
43+
});
44+
45+
this.Then(/^it install npm dependencies$/, function(cb) {
46+
// Write code here that turns the phrase above into concrete actions
47+
cb();
48+
});
49+
50+
this.Then(/^it creates the files:$/, function(files, cb) {
51+
console.log(files)
52+
cb();
53+
});
54+
55+
this.Then(/^it passes with:$/, function(string, callback) {
56+
// Write code here that turns the phrase above into concrete actions
57+
callback.pending();
58+
});
59+
};

0 commit comments

Comments
 (0)