Error while integrating html with testacularjs

后端 未结 2 1566
梦如初夏
梦如初夏 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:30

    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.

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题