Error while integrating html with testacularjs

后端 未结 2 1558
梦如初夏
梦如初夏 2021-02-15 12:52

How do I integrate (html) fixtures with testacular? Is there any recommendation for performing DOM based tests or is it an anti-pattern?

Objective : I am trying to test

2条回答
  •  执笔经年
    2021-02-15 13:32

    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

提交回复
热议问题