Hi,
I am doing the Quality Assurance and Testing with Chai course, and I am stuck on the second last and last challenges where I need to use Zombie.js to code functional tests in the browser.
Here are the instructions that FCC provides to complete the challenge :
test('Submit the surname "Polo" in the HTML form', function (done) {
browser.fill('surname', 'Polo').then(() => {
browser.pressButton('submit', () => {
browser.assert.success();
browser.assert.text('span#name', 'Marco');
browser.assert.text('span#surname', 'Polo');
browser.assert.elements('span#dates', 1);
done();
});
});
});
My package.json
{
"name": "automated-testing-app",
"version": "0.0.1",
"description": "Boilerplate for the Quality Assurance and Testing with Chai challenges",
"main": "server.js",
"scripts": {
"start": "node --watch server.js"
},
"dependencies": {
"body-parser": "1.19.0",
"chai": "4.3.4",
"chai-http": "4.3.0",
"cors": "2.8.5",
"express": "4.17.1",
"mocha": "9.0.3",
"zombie": "6.1.4"
},
"license": "MIT",
"directories": {
"test": "tests"
},
"repository": {
"type": "git",
"url": "git+https://github.com/freeCodeCamp/boilerplate-mochachai.git"
},
"keywords": [],
"author": "",
"type": "commonjs",
"bugs": {
"url": "https://github.com/freeCodeCamp/boilerplate-mochachai/issues"
},
"homepage": "https://github.com/freeCodeCamp/boilerplate-mochachai#readme"
}
And this is my Zombie.js and Chai setup
const Browser = require('zombie');
suite('Functional Tests with Zombie.js', function () {
this.timeout(5000);
Browser.site = 'http://127.0.0.1:3000/';
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('"Famous Italian Explorers" form', function () {
// #5
test('Submit the surname "Colombo" in the HTML form', function (done) {
browser.fill('surname', 'Colombo').then(() => {
browser.pressButton('submit', () => {
browser.assert.success();
browser.assert.text('span#name', 'Cristoforo');
browser.assert.text('span#surname', 'Colombo');
browser.assert.elements('span#dates', 1);
done();
});
});
});
// #6
test('Submit the surname "Vespucci" in the HTML form', function (done) {
browser.fill('surname', 'Vespucci').then(() => {
browser.pressButton('submit', () => {
browser.assert.success();
browser.assert.text('span#name', 'Armegio');
browser.assert.text('span#surname', 'Vespucci');
browser.assert.elements('span#dates', 1);
done();
});
});
});
});
});
The terminal gives out these error messages
Restarting 'server.js'
Listening on port 3000
Running Tests...
(node:99889) [DEP0176] DeprecationWarning: fs.F_OK is deprecated, use fs.constants.F_OK instead
(Use `node --trace-deprecation ...` to show where the warning was created)
Unit Tests
Basic Assertions
✔ #isNull, #isNotNull
✔ #isDefined, #isUndefined
✔ #isOk, #isNotOk
✔ #isTrue, #isNotTrue
Equality
✔ #equal, #notEqual
✔ #strictEqual, #notStrictEqual
✔ #deepEqual, #notDeepEqual
Comparisons
✔ #isAbove, #isAtMost
✔ #isBelow, #isAtLeast
✔ #approximately
Arrays
✔ #isArray, #isNotArray
✔ Array #include, #notInclude
Strings
✔ #isString, #isNotString
✔ String #include, #notInclude
✔ #match, #notMatch
Objects
✔ #property, #notProperty
✔ #typeOf, #notTypeOf
✔ #instanceOf, #notInstanceOf
Functional Tests
Integration tests with chai-http
✔ Test GET /hello with no name
✔ Test GET /hello with your name
✔ Send {surname: "Colombo"}
✔ Send {surname: "da Verrazzano"}
Functional Tests with Zombie.js
(node:99889) [DEP0044] DeprecationWarning: The `util.isArray` API is deprecated. Please use `Array.isArray()` instead.
Headless browser
✔ should have a working "site" property
"Famous Italian Explorers" form
1) Submit the surname "Colombo" in the HTML form
2) Submit the surname "Vespucci" in the HTML form
23 passing (64ms)
2 failing
1) Functional Tests with Zombie.js
"Famous Italian Explorers" form
Submit the surname "Colombo" in the HTML form:
Uncaught TypeError: isRegExp is not a function
at assertMatch (node_modules/zombie/lib/assert.js:22:7)
at Assert.text (node_modules/zombie/lib/assert.js:184:5)
at /Users/qingyan/Desktop/Computing Self Study/FCC Quality Assurance/Learn Quality Assurance with Chai/boilerplate-mochachai/tests/2_functional-tests.js:94:26
at EventLoop.done (node_modules/zombie/lib/eventloop.js:424:9)
at Object.onceWrapper (node:events:622:28)
at EventLoop.emit (node:events:520:35)
at Immediate.<anonymous> (node_modules/zombie/lib/eventloop.js:515:65)
at process.processImmediate (node:internal/timers:505:21)
2) Functional Tests with Zombie.js
"Famous Italian Explorers" form
Submit the surname "Vespucci" in the HTML form:
Uncaught TypeError: isRegExp is not a function
at assertMatch (node_modules/zombie/lib/assert.js:22:7)
at Assert.text (node_modules/zombie/lib/assert.js:184:5)
at /Users/qingyan/Desktop/Computing Self Study/FCC Quality Assurance/Learn Quality Assurance with Chai/boilerplate-mochachai/tests/2_functional-tests.js:106:26
at EventLoop.done (node_modules/zombie/lib/eventloop.js:424:9)
at Object.onceWrapper (node:events:622:28)
at EventLoop.emit (node:events:520:35)
at Immediate.<anonymous> (node_modules/zombie/lib/eventloop.js:515:65)
at process.processImmediate (node:internal/timers:505:21)
All the tests except the first one is failing, which I think is caused by perhaps some old version of Zombie.js being used in the challenge. Any help on how to solve this problem would be appreciated, thanks!

