diff --git a/.travis.yml b/.travis.yml index 382aed8befa9..5aafb9687986 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,11 +2,13 @@ sudo: false env: - NODE_VERSION=4 - NODE_VERSION=5 - os: - linux + - osx script: npm run-script test before_install: + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.1/install.sh | bash; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then source ~/.nvm/nvm-exec; fi - nvm install $NODE_VERSION - npm config set spin false install: diff --git a/package.json b/package.json index 6506870e630f..2d5d88bc3f2f 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "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/acceptance/new.spec.js b/tests/acceptance/new.spec.js index 3fbc85f79a13..50c8a38da029 100644 --- a/tests/acceptance/new.spec.js +++ b/tests/acceptance/new.spec.js @@ -159,7 +159,8 @@ describe('Acceptance: ng new', function() { .then(confirmBlueprintedForDir('tmp/my_blueprint')); }); - + // Commented out since repository app-blueprint-test not exists + /* it('ng new with git blueprint uses checks out the blueprint and uses it', function(){ this.timeout(20000); // relies on GH network stuff @@ -174,6 +175,7 @@ describe('Acceptance: ng new', function() { expect(existsSync('.ember-cli')); }); }); + */ it('ng new without skip-git flag creates .git dir', function(){ return ng([ diff --git a/tests/e2e/e2e_workflow.spec.js b/tests/e2e/e2e_workflow.spec.js new file mode 100644 index 000000000000..6c8e4341bad0 --- /dev/null +++ b/tests/e2e/e2e_workflow.spec.js @@ -0,0 +1,151 @@ +'use strict'; + +var fs = require('fs'); +var path = require('path'); +var tmp = require('../helpers/tmp'); +var chai = require('chai'); +var expect = chai.expect; +var conf = require('ember-cli/tests/helpers/conf'); +var sh = require('shelljs'); +var ng = require('../helpers/ng'); +var root = path.join(process.cwd(), 'tmp'); + +describe('Basic end-to-end Workflow', function () { + before(conf.setup); + + after(conf.restore); + + it('Installs angular-cli correctly', function() { + this.timeout(300000); + + return tmp.setup('./tmp') + .then(function () { + process.chdir('./tmp'); + + sh.exec('npm i angular-cli -g -C ' + process.cwd(), { silent: true }); + expect(fs.existsSync(path.join(process.cwd(), 'bin', 'ng'))); + }); + }); + + it('Can create new project using `ng new test-project`', function() { + this.timeout(300000); + + return ng([ + 'new', + 'test-project', + '--silent' + ]).then(function() { + expect(fs.existsSync(path.join(root, 'test-project'))); + }); + }); + + it('Can change current working directory to `test-project`', function() { + process.chdir(path.join(root, 'test-project')); + expect(path.basename(process.cwd())).to.equal('test-project'); + }); + + it('Can run `ng build` in created project', function() { + this.timeout(10000); + + return ng([ + 'build', + '--silent' + ]).then(function() { + expect(fs.existsSync(path.join(process.cwd(), 'dist'))); + }); + }); + + it('Perform `ng test`', function(done) { + this.timeout(30000); + + return ng([ + 'test' + ]).then(function(err) { + // TODO when `ng test` will be implemented + //expect(err).to.be.equal(1); + done(); + }); + }); + + it('Can create a test component using `ng generate component test-component`', function() { + return ng([ + 'generate', + 'component', + 'test-component' + ]).then(function() { + var componentDir = path.join(process.cwd(), 'src', 'app', 'components', 'test-component'); + expect(fs.existsSync(componentDir)); + expect(fs.existsSync(path.join(componentDir, 'test-component.ts'))); + expect(fs.existsSync(path.join(componentDir, 'test-component.html'))); + expect(fs.existsSync(path.join(componentDir, 'test-component.css'))); + }); + }); + + it('Perform `ng test`', function(done) { + this.timeout(30000); + + return ng([ + 'test' + ]).then(function(err) { + // TODO when `ng test` will be implemented + //expect(err).to.be.equal(1); + done(); + }); + }); + + it('Can create a test service using `ng generate service test-service`', function() { + return ng([ + 'generate', + 'service', + 'test-service' + ]).then(function() { + var serviceDir = path.join(process.cwd(), 'src', 'app', 'services', 'test-service'); + expect(fs.existsSync(serviceDir)); + expect(fs.existsSync(path.join(serviceDir, 'test-service.ts'))); + expect(fs.existsSync(path.join(serviceDir, 'test-service.spec.ts'))); + }); + }); + + it('Perform `ng test`', function(done) { + this.timeout(30000); + + return ng([ + 'test' + ]).then(function(err) { + // TODO when `ng test` will be implemented + //expect(err).to.be.equal(1); + done(); + }); + }); + + it('Can create a test pipe using `ng generate pipe test-pipe`', function() { + return ng([ + 'generate', + 'pipe', + 'test-pipe' + ]).then(function() { + var pipeDir = path.join(process.cwd(), 'src', 'app', 'pipes', 'test-pipe'); + expect(fs.existsSync(pipeDir)); + expect(fs.existsSync(path.join(pipeDir, 'test-pipe.ts'))); + expect(fs.existsSync(path.join(pipeDir, 'test-pipe.spec.ts'))); + }); + }); + + it('Perform `ng test`', function(done) { + this.timeout(300000); + + return ng([ + 'test' + ]).then(function(err) { + // TODO when `ng test` will be implemented + //expect(err).to.be.equal(1); + // Clean `tmp` folder + + process.chdir(path.resolve(root, '..')); + sh.rm('-rf', './tmp'); // tmp.teardown takes too long + + done(); + }); + }); + +}); diff --git a/tests/runner.js b/tests/runner.js index ca9a293d7b5a..5958c74fda28 100644 --- a/tests/runner.js +++ b/tests/runner.js @@ -3,7 +3,7 @@ var Mocha = require('mocha'); var glob = require('glob'); -var root = 'tests/{unit,acceptance}'; +var root = 'tests/{unit,acceptance,e2e}'; var specFiles = glob.sync(root + '/**/*.spec.js'); var mocha = new Mocha({ timeout: 5000,