UPDATE: I finally got the tests to run by doing something differently, though I still don’t understand why the code I show in this post doesn’t work. Just a heads-up so that no one wastes their time, unless you’re on the mood for a debugging challenge, of course.
I apologize in advance for the whining, but I think everyone here knows what it’s like when you’ve been sitting in front of your PC for HOURS and still get absolutely nowhere. I’m at my wit’s end with the issue tracker and the Quality Assurance & Adv. Node & Express unit. I have never posted on the forum as often as I have with this one, and I previously completed 6 units.
I really need help here, because I truly don’t know what’s failing, let alone what to do.
I last posted 6 hs ago after solving a different problem and all I had left to do was write the Functional Tests. 6 hours later, I haven’t even been able to run a single test. And the code for my functional-tests file looks EXACTLY like the code that passes all the challenges of “Quality Assurance and Testing with Chai”. It’s the exact same configuration, yet all I get is this error message:
1) Functional Tests
"before all" hook in "Functional Tests":
http://0.0.0.0:3000/:script:2
$(function() {
^
ReferenceError: $ is not defined
This is my code, and I must stress that it’s the same code that correctly runs and passes the challenges for the lessons, yet it doesn’t even run now (of course, the only difference are the names of some input fields.
const chai = require('chai');
const assert = chai.assert;
const server = require('../server');
const chaiHttp = require('chai-http');
chai.use(chaiHttp);
const Browser = require('zombie');
// Browser.site="http://localhost:3000";
Browser.site="http://0.0.0.0:3000";
suite('Functional Tests', function() {
this.timeout(5000);
const browser = new Browser();
suiteSetup(function(done) {
return browser.visit("/", done)
});
suite('Headless browser', function () {
test('should have a working "site" property', function() {
assert.isNotNull(browser.site);
});
});
suite("POST tests", function () {
test("Create an issue with every field: POST request to /api/issues/{project}", function (done) {
browser.fill('input[name="issue_title"]', "Prueba1")
.fill("issue_text", "This is a test")
.fill("created_by", "Rodrigo")
.fill("assigned_to", "Steve")
.fill("status_text", "A-OK")
.then(() => {
browser.pressButton("#testForm1 button[type='submit']", () => {
browser.assert.success();
browser.assert.text("issue_title", "Prueba1");
browser.assert.text("issue_text", "This is a test");
browser.assert.text("created_by", "Rodrigo");
browser.assert.text("assigned_to", "Steve");
browser.assert.text("status_text", "A-OK");
done();
})
})
.catch((error) => {
done(error);
});
})
})
});
Please don’t mind whether the test themselves are correctly written. The problem is that they won’t even run.
FAQ:
- Tried using
Browser.site="http://localhost:3000"
instead ofBrowser.site="http://0.0.0.0:3000";
. When I do that, the error message is
- Functional Tests
“before all” hook in “Functional Tests”:
TypeError: bind EINVAL 0.0.0.0
- If I keep
Browser.site="http://0.0.0.0:3000"
and change the suiteSetup to
suiteSetup(function(done) {
return browser.visit("/", done())
});
then tests run and one passes, but the second one doesn’t and returns this error message:
AssertionError [ERR_ASSERTION]: No open window with an HTML document
(mind that the second ‘done’ is now ‘done()’ , which I was told should never be the case but was the only thing that worked in a previous project)
- and if I use
suiteSetup(function(done) {
return browser.visit("/", done())
});
and
Browser.site="http://localhost:3000"
the tests run too, but the second one fails with the message:
AssertionError [ERR_ASSERTION]: No INPUT matching 'input[name="issue_title"]'
(it’s a convoluted reference, but I can assure you it’s correct. I’ve also tried it with #issue_title
after adding id="issue_title"
to the input in .html file, and it doesn’t work either.
Please, I’m sorry to be posting here as often as I have these past two weeks, but I’ve spent an unhealthy amount of hours on this unit and project, and the fact that I can’t even get started when I’m using the exact same configuration that worked in the lessons is very frustrating and desorienting.