Javascript 使用角度场景测试';任何网页';

Javascript 使用角度场景测试';任何网页';,javascript,angularjs,dojo,karma-runner,Javascript,Angularjs,Dojo,Karma Runner,我想知道是否有可能用AngularScenarioTester(和karma)测试任何网页 或者它只设计用于角度源代码 换句话说,它是否是一个与角度无关的泛型 我正在和约曼一起编写一个angularJs应用程序,感谢ngResource,我喜欢e2e测试的方式 我有另一个应用程序,不是用angular编写的,而是用dojo编写的,我想用同样的方法测试它 你认为有可能吗?如果有,你对如何做有什么建议 谢谢大家! 注意:事实上,测试的网页中是否有一些角度代码,所以这个问题是有意义的。casperJs

我想知道是否有可能用AngularScenarioTester(和karma)测试任何网页

或者它只设计用于角度源代码

换句话说,它是否是一个与角度无关的泛型

我正在和约曼一起编写一个angularJs应用程序,感谢ngResource,我喜欢e2e测试的方式

我有另一个应用程序,不是用angular编写的,而是用dojo编写的,我想用同样的方法测试它

你认为有可能吗?如果有,你对如何做有什么建议

谢谢大家!


注意:事实上,测试的网页中是否有一些角度代码,所以这个问题是有意义的。casperJs或selenium等工具独立于页面中的js技术。

因此很容易实现。你只需要

1/安装卡玛

npm安装-g karma

2/为ng场景和karma ng场景安装依赖项

3/如果需要代理,创建/修改karma e2e配置。是这样的 通常,dojo运行在与karma不同的服务器上。那么你呢 为karma指定一个特定端口,然后代理服务器。在这里 以下是我的配置示例:

module.exports=函数(config){config.set({ //基本路径,将用于解析文件和排除 基本路径:“”

  • 您使用端到端配置运行karma
  • Magic,下面的代码可以工作-快乐测试:)


    请注意,一些测试代码可以工作(例如计数元素),而另一些则不行(例如设置输入不通过角度调整)

    下面是一个工具,它尝试使NGSCHENATIONS与任何JS工具一起工作:

    npm install ng-scenario
    
    npm install karma-ng-scenario --save-dev
    
    // testing framework to use (jasmine/mocha/qunit/...)
    frameworks: ['ng-scenario'],
    
    // list of files / patterns to load in the browser
    files: [
       'https://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js',
      'test/e2e/**/*.js'
    ],
    
    // list of files / patterns to exclude
    exclude: [],
    
    // web server port
    port: 8033,
    
    runnerPort : 9100,
    
    // level of logging
    // possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
    logLevel: config.LOG_INFO,
    
    
    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: false,
    
    
    // Start these browsers, currently available:
    // - Chrome
    // - ChromeCanary
    // - Firefox
    // - Opera
    // - Safari (only Mac)
    // - PhantomJS
    // - IE (only Windows)
    browsers: ['Chrome'],
    
    
    // Continuous Integration mode
    // if true, it capture browsers, run tests and exit
    singleRun: false,
    
    // Uncomment the following lines if you are using grunt's server to run the tests
    proxies: {
       '/': 'http://localhost:8080/'
    }, //    URL root prevent conflicts with the site root
    urlRoot: '_karma_'   }); };
    
    karma start karma-e2e.conf.js
    
    describe ( 'Publications', function ()
    {
       beforeEach (
          function ()
          {
             console.log ( "before each" );
             browser ().navigateTo ( "yourPageToTestUrl" );
          }
       );
    
       it ( 'should filter results', function ()
       {
          expect ( repeater ( '.Publication' ).count () ).toEqual ( 4 );
       } );
    
    } );