Eslint没有运行Polymer元素的web-component-tester测试

时间:2016-07-14 08:05:41

标签: testing gulp polymer eslint web-component-tester

我正在尝试使用eslint在gulp上为我的Polymer元素运行测试,但它似乎没有找到我所包含的browser.js文件,因为它返回的内容如“错误'套件'未定义无是undef”。

我的gulpfile.js:

'use strict';

var gulp = require('gulp');
var wct = require('web-component-tester').test;
var $ = require('gulp-load-plugins')();

gulp.task('lint', function (){
    return gulp.src(["test/visualization-app/*.html"])
        .pipe($.eslint())
        .pipe($.eslint.format())
        .pipe($.eslint.failAfterError());
});

gulp.task('default', ['lint'], function() {

});

这是我使用的测试套件:

<!doctype html>

<html>
  <head>
    <title>visualization-app test</title>
    <meta charset = "utf-8">
    <meta name = "viewport" content = "width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
    <script src = "../../bower_components/webcomponentsjs/webcomponents-lite.js"></script>
    <script src = "../../bower_components/web-component-tester/browser.js"></script>
    <link rel="import" href="../../src/visualization-app/visualization-app.html">
  </head>
  <body>

    <test-fixture id="basic">
      <template>
        <visualization-app></visualization-app>
      </template>
    </test-fixture>

    <script>
      suite('visualization-app', function() {

          test('instantiating the element works', function() {
              //Simply trying to show my test results on the console
              assert.isTrue(false);
          });

      });
    </script>
  </body>
</html>

最后是这个测试的gulp命令:

 D:\rtdb\elk\rtdb-polymer>gulp
[10:48:25] Using gulpfile D:\rtdb\elk\rtdb-polymer\gulpfile.js
[10:48:25] Starting 'lint'...
[10:48:26]
D:\rtdb\elk\rtdb-polymer\test\visualization-app\visualization-app_test.html
  21:7   error  'suite' is not defined   no-undef
  23:11  error  'test' is not defined    no-undef
  25:15  error  'assert' is not defined  no-undef

? 3 problems (3 errors, 0 warnings)

[10:48:26] 'lint' errored after 624 ms
[10:48:26] ESLintError in plugin 'gulp-eslint'
Message:
    Failed with 3 errors

我对所有这些工具和一般的网络开发都很陌生,所以必须有一些非常简单的东西,我做得不对,但24小时后我似乎无法找到。

编辑:我确实安装了eslint-plugin-html并在我的.eslintrc.json上

0 个答案:

没有答案