diff --git a/index.js b/index.js index 1c87ec7..92fdaad 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,7 @@ var fs = require('fs'), mkdirp = require('mkdirp'), _ = require('lodash'), path = require('path'), + async = require('async'), hat = require('hat'); require('string.prototype.startswith'); @@ -142,6 +143,7 @@ function Jasmine2HTMLReporter(options) { spec._suite = currentSuite; currentSuite._specs.push(spec); }; + self.specDone = function(spec) { spec = getSpec(spec); spec._endTime = new Date(); @@ -159,19 +161,17 @@ function Jasmine2HTMLReporter(options) { spec.screenshot = sanitizeFilename(spec.description) + '.png'; browser.takeScreenshot().then(function (png) { - browser.getCapabilities().then(function (capabilities) { - var screenshotPath; - - - //Folder structure and filename - screenshotPath = path.join(self.savePath + self.screenshotsFolder, spec.screenshot); - - mkdirp(path.dirname(screenshotPath), function (err) { - if (err) { - throw new Error('Could not create directory for ' + screenshotPath); - } - writeScreenshot(png, screenshotPath); - }); + var screenshotPath = path.join( + self.savePath, + self.screenshotsFolder, + spec.screenshot + ); + + mkdirp(path.dirname(screenshotPath), function (err) { + if (err) { + throw new Error('Could not create directory for ' + screenshotPath); + } + writeScreenshot(png, screenshotPath); }); }); } @@ -187,6 +187,7 @@ function Jasmine2HTMLReporter(options) { suite._endTime = new Date(); currentSuite = suite._parent; }; + self.jasmineDone = function() { if (currentSuite) { // focused spec (fit) -- suiteDone was never called diff --git a/package.json b/package.json index 10f8407..6fddca4 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ }, "repository": { "type": "git", - "url": "https://github.com/Kenzitron/protractor-jasmine2-html-reporter" + "url": "https://github.com/Kenzitron/protractor-jasmine2-html-reporter", + "postinstall": "./node_modules/protractor/bin/webdriver-manager update" }, "keywords": [ "jasmine2", @@ -27,13 +28,14 @@ "url": "https://github.com/Kenzitron/protractor-jasmine2-html-reporter/issues" }, "dependencies": { - "hat": "0.0.3", - "lodash": "^4.0.0", + "async": "^2.1.4", + "hat": "^0.0.3", + "lodash": "^4.17.0", "mkdirp": "^0.5.0", "string.prototype.startswith": "^0.2.0" }, "devDependencies": { - "jasmine": "^2.4.1", - "protractor": "^3.1.1" + "jasmine": "^2.5.2", + "phantomjs": "^2.1.7" } } diff --git a/protractor.config.js b/protractor.config.js index cc34e59..c89cc0b 100644 --- a/protractor.config.js +++ b/protractor.config.js @@ -3,21 +3,24 @@ exports.config = { // Capabilities to be passed to the webdriver instance. capabilities: { - 'browserName': 'chrome' + 'browserName': 'phantomjs' }, framework: 'jasmine2', - directConnect: true, + //directConnect: true, specs: ['test/**/*[sS]pec.js'], onPrepare: function() { - var Jasmine2HtmlReporter = require('./index.js'); + return global.browser.getProcessedConfig().then(function (config) { + var Jasmine2HtmlReporter = require('./index.js'); + + jasmine.getEnv().addReporter(new Jasmine2HtmlReporter({ + savePath: './test/reports/' + })); + }); - jasmine.getEnv().addReporter(new Jasmine2HtmlReporter({ - savePath: './test/reports/' - })); } }; \ No newline at end of file diff --git a/test/test3Spec.js b/test/test3Spec.js new file mode 100644 index 0000000..4005ed7 --- /dev/null +++ b/test/test3Spec.js @@ -0,0 +1,29 @@ +xdescribe('SPEC 2', function() { + + it('2 should add a todo', function() { + browser.get('http://www.angularjs.org'); + + element(by.model('todoList.todoText')).sendKeys('write a protractor test'); + element(by.css('[value="add"]')).click(); + + var todoList = element.all(by.repeater('todo in todoList.todos')); + expect(todoList.count()).toEqual(3); + expect(todoList.count()).toEqual(6); //Failure + expect(todoList.get(2).getText()).toEqual('write a protractor test'); + }); + + it('2 second it', function() { + browser.get('http://www.angularjs.org'); + + element(by.model('todoList.todoText')).sendKeys('write a protractor test'); + element(by.css('[value="add"]')).click(); + + var todoList = element.all(by.repeater('todo in todoList.todos')); + expect(todoList.count()).toEqual(3); + expect(todoList.count()).toEqual(3); + expect(todoList.count()).toEqual(3); + expect(todoList.count()).toEqual(3); + expect(todoList.get(2).getText()).toEqual('write a protractor test'); + }); + +}); \ No newline at end of file