1

I'm attempting to run integration tests via grunt-contrib-qunit. I've set the --proxy flag via the options object, every ajax request returns a 404 (not found) error.

Gruntfile.js

grunt.loadNpmTasks('grunt-contrib-qunit');
...

grunt.initConfig({
  qunit: {
    options: {
      '--local-to-remote-url-access': true,
      '--proxy': '192.168.1.1:8080'
    },
    all: [
      'test/**/*.html'
    ]
  },
  ...
});

...

grunt.registerTask('test', [
  'clean:server',
  'compass',
  'connect:test',
  'qunit:all'
]);

The QUnit test itself fails with a 404 on the most trivial AJAX request:

test/index.html

test('Works', function() {
  stop();
  $.ajax({
    url: '/svc/version',
    success: function() {
      ok(true, 'yippee');
      start();
    },
    error: function(xhr) {
      console.log('Error: ' + xhr.status);
    }
  });
});

Fails with:

Running "qunit:all" (qunit) task
Testing test/index.htmlError: 404

It's worth noting that explicitly referencing the host (url: 'http://192.168.1.1:8080/svc/version') works fine, so it's not a same-origin issue.


References: grunt-contrib-qunit, PhantomJS, grunt-lib-phantomjs, SO "Proxy in PhantomJS"

4

0 に答える 0