I think there is a problem with the tests running for Quality Assurance and Testing with Chai. Specifically, the tests for assert.typeOf() and assert.notTypeOf() dealing with the object properties of Car and Plane.
If I run the tests two or three times in a row, without ever changing my code, I get different pass/fail results every time. I even went and peeked at the Solution out of confusion. When I made my code match the solution given, my tests still failed.
Has anyone else gotten stuck here with the tests appearing to not behave properly? How can we get these to pass?
My code so far
// -----------------------------------------------------------------------------
// These variables are used in the tests. Don't Edit them.
var Car = function() {
this.model = 'cedan';
this.engines = 1;
this.wheels = 4;
};
var Plane = function() {
this.model = '737';
this.engines = ['left', 'right'];
this.wheels = 6;
this.wings = 2;
};
var myCar = new Car();
var airlinePlane = new Plane();
suite('Objects', function(){
/** 16 - #property asserts that the actual object has a given property. **/
// Use #property or #notProperty where appropriate
test('#property, #notProperty', function() {
assert.notProperty(myCar, 'wings', 'A car has not wings');
assert.property(airlinePlane, 'engines', 'planes have engines');
assert.property(myCar, 'wheels', 'Cars have wheels');
});
test('#typeOf, #notTypeOf', function() {
/** 17 #typeOf asserts that value’s type is the given string, **/
// as determined by Object.prototype.toString.
// Use #typeOf or #notTypeOf where appropriate
assert.typeOf(myCar, 'object');
assert.typeOf(myCar.model, 'string');
assert.notTypeOf(airlinePlane.wings, 'string');
assert.typeOf(airlinePlane.engines, 'array');
assert.typeOf(myCar.wheels, 'number');
});
test('#instanceOf, #notInstanceOf', function() {
/** 18 #instanceOf asserts that an object is an instance of a constructor **/
// Use #instanceOf or #notInstanceOf where appropriate
assert.fail(myCar, Plane);
assert.fail(airlinePlane, Plane);
assert.fail(airlinePlane, Object, 'everything is an Object');
assert.fail(myCar.wheels, String );
});
});
// -----------------------------------------------------------------------------
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36
.
Challenge: Test if a Value is of a Specific Data Structure Type
Link to the challenge:
https://www.freecodecamp.org/learn/information-security-and-quality-assurance/quality-assurance-and-testing-with-chai/test-if-a-value-is-of-a-specific-data-structure-type