Giter Site home page Giter Site logo

ramonvictor / gulp-protractor-qa Goto Github PK

View Code? Open in Web Editor NEW
59.0 7.0 18.0 18.79 MB

Warns whether Protractor locators have their matches within a given set of AngularJS view files

Home Page: https://www.npmjs.org/package/gulp-protractor-qa

License: MIT License

JavaScript 93.35% HTML 6.65%

gulp-protractor-qa's Introduction

gulp-protractor-qa NPM version Build Status

Protractor QA Logo

Keeping end-to-end tests up-to-date can be really painful. Gulp Protractor QA can help us by warning whether protractor locators have their matches within a given set of AngularJS view files.

Because code changes should not break our tests!

How it works?

Video screen demo of gulp-protractor-qa in action!

How gulp-protractor-qa works?

TL;DR: a couple of new features and fixes have been added since this screencast publication.

Install

npm install --save-dev gulp-protractor-qa

Example

var gulp = require('gulp');
var protractorQA = require('gulp-protractor-qa');

Registering the task

gulp.task('protractor-qa', function() {
   protractorQA.init({
      runOnce: true, // optional
      testSrc: 'test/e2e/**/*Spec.js',
      viewSrc: [ 'index.html', 'partials/*.html' ]
   });
});

Running it

gulp.task('default', ['protractor-qa']);

See final gulpfile.js example.

API

protractorQA(options)

options

runOnce

Type: Boolean Default: false

Optional: Set to true when you want to control yourself when to run task. In other words, it won't watch files changes.

testSrc

Type: String or Array Default: ""

Where the plugin should watch the changes in order to map all element() indexes.

viewSrc

Type: String or Array Default: ""

Where your AngularJS view files are located. Protractor QA will watch the changes in those files to verify if all element() selectors could be found.

Watched selectors by gulp-protractor-qa

Gulp-protractor-qa is currently watching the following element() locators:

  • by.binding();
  • by.model();
  • by.repeater();
  • by.css();
  • by.id();
  • by.className();
  • by.name();

Note: currently it can't find by.css() selectors with :nth-child().

Changelog

  • 0.2.0 api completely rewritten, including:

    • Introducing runOnce feature;
    • Ignoring commented out element selectors;
    • Handle any form of denormalized directives - except ng:* due to cheerio limitation;
    • Fix a couple of bugs related to by.css old regex;
    • Add suport for more protractor locators: by.id(), by.className() and by.name().
  • 0.1.19 improve by.css regex;

  • 0.1.18 bug fix: adding support for data-* attributes;

  • 0.1.14 showing "<number> out of <total> element selectors are been watched" in the log;

  • 0.1.12 bug fix related to gaze version;

  • 0.1.10 testSrc and viewSrc now receive string or array value;

  • 0.1.07

    • Improved the error log showing in which file each wrong selector came from;
    • Improved the regex that find selectors by: by.css('[attr-name="attr-value"]');
  • 0.1.05

    • Mapping more element() selectors: by.css('[attr-name="attr-value"]') and by.binding();
    • Improve regex rules to support both: protractor.By and by.;
    • Other code improvements;
  • 0.1.0 Mapping just two element() selectors: by.model() and by.repeater().

License

MIT © Ramon Victor

gulp-protractor-qa's People

Contributors

doshprompt avatar ramonvictor avatar razielron avatar stramel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gulp-protractor-qa's Issues

Commented out element selectors still output error

Element selectors in spec/suite files that are commented out still output errors:

//it('should have a list of things', function() {
//  expect(element.all(by.repeater('thing in things')).count()).toBeGreaterThan(4);
//});

Which will result in:

[gulp] [gulp-protractor-qa] by.repeater('thing in things') at <some-spec-file> not found in view files!

... when the view doesn't include that repeater.

Instead protractor-qa should ignore these commented out element selectors.

testSrc and viewSrc should be able to read array

Developers may have different folders with their view files. e.g.: "./index.html", "./partials/*/.html", "js/directives.js"[1].

[1] directives.js may have 'template' property declared, so it will probably have bindings/repeaters/attrs to verify.

Improve cssAttrs regex

Some regex rules to consider:

  1. Strings should start with alphanumeric and should not start with '#' and '.';
  2. Has '=' string.

pageObjects with dynamic attributes in locators not working

Hello

Protractor-qa does not recognize this type of selectors I have in my pageObjects !
With dynamic attributes or variables.

var myFunc = function (name) {
  return element(by.css('h1[attr-name="' + name + '"]'));
};

or

var myFunc = function (myClass) {
  return element(by.css(myClass));
};

[FEATURE] Run Once

I would like to use this plugin in 2 ways:

  1. Run once and no watching of files before my protractor tests are ran manually
  2. Continuously, as in development.

I think it would be an easy implementation to make it run once and would be a great feature for this plugin.

Installation failed

I tried today, and installation failed.
node version 0.10.26
npm version 1.4.3

gyp ERR! configure error
gyp ERR! stack Error: spawn ENOENT
gyp ERR! stack at errnoException (child_process.js:988:11)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:779:
34)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\Program Files\nodejs\node_modules\npm\node_modu
les\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\dev\node_modules\gulp-protractor-qa\node_modules\gaze
gyp ERR! node -v v0.10.26
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the gaze package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls gaze
npm ERR! There is likely additional logging output above.

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nod
ejs\node_modules\npm\bin\npm-cli.js" "install" "--save-dev" "gulp-protractor
-qa"
npm ERR! cwd C:\dev
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\dev\npm-debug.log
npm ERR! not ok code 0

Element watcher is not working/starting

it's just start and finish the "default & protractor-qa" tasks, with no watching for the elements

and for a case, it gives me this :: " ..\node_modules\gulp-protractor-qa\lib\find-view-matches.js:75
return value.indexOf(prefix) === 0 ? value : prefix + value; "
"TypeError: Cannot read property 'indexOf' of undefined"
I took some screenshots.

gulp-protractor-qa-err00
gulp-protractor-qa-err01

Cant watch by.css locator

i have a page object that has locators by.model and by.css,
screen shot 2015-10-14 at 10 45 03 am
but when i ran the gulp task the result is
screen shot 2015-10-14 at 10 46 47 am
the by.model locator only is being watch. @ramonvictor any thoughts? thanks in advance!

Unable to track the HTML page changes

@ramonvictor At fist thanks a ton for this awesome plugin which helps for qa guys. I tried you plugin and it works well when there is are changes happened in spec.js files. But for html page it is not recognizing the changes. Here are the steps -

1 - I just saved my app angular page as html doc
2 - Placed in my framework and config the file gulpfile.js
3- When I modify the element information in html file your plugin is not identifying them
4- If I remove that html file completely then it should the red marks for the locators in spec.js file

Any advise ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.