Error while integrating html with testacularjs

馋奶兔 提交于 2019-12-03 13:07:37

Current version of testacularjs cannot support this. However, the author of testacularjs(Vojta Jina), suggested I use a proxy solution to workaround this by serving the html through a different web server. For those curious, here are the end to end steps to get this working.

  • First run the webserver by running a command like the following

    python -m SimpleHTTPServer 3502 &

  • Drop your fixture file(s) in appropriate location. Mine was test/fixtures/first.html

    Now you should be able to visit [http://localhost:3502/test/fixtures/first.html] and see the markup when you inspect page source

  • Edit testacular.conf.js to add the config block

    
    proxies = {
    '/fixtures' : 'http://localhost:3502/'
    };
    
  • Edit your jasmine unit test to have a block like the following

    
    beforeEach(function(){
            jasmine.getFixtures().fixturesPath = '/fixtures/test/fixtures';
        });
    

Now you should be in a position to loadfixture/readfixture

As stated on http://testacular.github.com/0.6.0/config/files.html, since version 0.5.2 you can use the new configuration syntax:

files = [
  JASMINE,
  JASMINE_ADAPTER,
  'test/spec/**/*.js',
  {
    pattern: 'test/fixtures/*.html',
    watched: true,
    included: false,
    served: true
  }
];

I just tried it and it works fine for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!