felixzapata / gulp-axe-webdriver

Gulp plugin for aXe utilizing WebDriverJS
MIT License
24 stars 7 forks source link

Using streams #13

Open okeul opened 6 years ago

okeul commented 6 years ago

Hello !

First of all, thank you for the work done.

Sorry to create another issue (duplicate of https://github.com/felixzapata/gulp-axe-webdriver/issues/1), but I would like to use this plugin with streams.

I tried this :

var paths = require('../../paths');
var watch = require('../watch');
var plumberLazypipe = require('../../lib/lazypipes/plumber');

module.exports = function(gulp, plugins) {
  return function() {
    var src = paths.dest;
    if (paths.dir) {
      src = src + '/' + paths.dir;
    }
    src = src + '/**/*.{htm,html,jshtml,shtml}';

    watch.create(gulp, plugins, src, 'lint-a11y', 'watch-lint-a11y');

    return gulp.src(src, {
      base: paths.dest
    })
      .pipe(plumberLazypipe(plugins)())
      .pipe(plugins.axeWebdriver({
        headless: true,
        urls: [src]
      }));
  };
};

It works almost but I still have an error in the console about pipe (indeed because this plugin isn't intended to work with a stream).

log

Do you have any idea ?

felixzapata commented 6 years ago

hi @okeul , my first attempt with the plugin was to use it with streams.

But, as I replied to the previous issue, with the pipe system you can't check remote urls. For this plugin, I "sacrificed" (against what a gulp plugin should do) the pipe system to allow check local and remote files.

Related with this pull request I am working on a version of this plugin to use it with promises instead of with callbacks.

okeul commented 6 years ago

Thanks for your quick answer.

So about this PR, it will be possible to use streams with promises ? that's sound great !

felixzapata commented 6 years ago

I'm trying to use it with promises, but not with streams. Something like this:

gulp.task('axe', function(done) {
  var options = {
    saveOutputIn: 'allHtml.json',
    urls: ['http://www.foobar-url-1/', 'http://www.foobar-url-2/']
  };
  return axe(options).then(done);
});
ryuran commented 6 years ago

Hello @felixzapata We work currently on a static page builder to make pages mockup and we want test a11y on each pages built. But we are not able to know the list. So urls parameter does not answer to our need. It’s why we are looking for a plugin built for stream using gulp.src.

felixzapata commented 6 years ago

hi @ryuran , can you send your files to the urls attribute inside the plugin?

ryuran commented 6 years ago

@felixzapata It's what I tried at first. I finally choose to make our small gulp plugin to pipe some html files in it. I can chain other tests by pipe on it. I can watch new built html file.

https://github.com/cleverage/garden-starter-kit/pull/142/files#diff-e32e91d635b8d4053425d280792333fb

Thanks for the reporter function

I should make a independent gulp plugin with doc and test.

felixzapata commented 6 years ago

ok @ryuran. I will think if is possible to use the streams without lost the possibility to pass a url to the task. You are not the first one who request the stream system but as I told in a previous comment, my first attempt with the plugin was to use it with streams. But with this system I could not check remote urls. For this plugin, I sacrificed (against what a gulp plugin should do) the pipe system to allow check local and remote files.

Maybe the users prefer to test local files instead of local or remote urls.

ryuran commented 6 years ago

Yes, I understand this choice. This plugin is usefull for quality control on final product.

If we want use it with stream it's only because we use it in developement process.

I will try to make it work on both ways. I understand better how it's work now.

felixzapata commented 6 years ago

if you can make the plugin works in both ways, you can make a pull request

okeul commented 6 years ago

Hi @felixzapata,

Related with this pull request I am working on a version of this plugin to use it with promises instead of with callbacks.

Did you use promises instead of callbacks ? I don't think so but maybe i'm wrong.

The "bug" with streams it's still here :

gulp-axe-webdriver
var gulp = require('gulp');
var a11y = require('gulp-axe-webdriver');

gulp.task('test:a11y', 'Lint HTML files for accessibility.', function () {
  var src = 'build/pages/**/*.html';
  return gulp.src(src)
    .pipe(a11y({
      headless: true,
      urls: [src]
    }))
});

Any idea ?

felixzapata commented 6 years ago

hi, yes. Since the version 3 the plugin works with promises but about the streams I say the same as my previous comments.

My first attempt with the plugin was to use it with streams.

For this plugin, I "sacrificed" (against what a gulp plugin should do) the pipe system to allow check local and remote files.

To summarize, in order to use streams with the plugin, it would be necessary to remove the option to check urls.

I don't know how many people use the plugin to check local files vs urls, so at the moment, I have no plan to modify the plugin to allow the streams.

okeul commented 6 years ago

Ok i understand.