Quality Assurance and Testing with Chai - Tests not working properly

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:

Are you running the project on Glitch?

Yes, this is the link I provide for the tests.

Oddly enough, after seeing your comment and responding, my tests just passed twice in a row. But I assure you with this same glitch project, same code I posted, etc., these tests were failing just a few minutes ago. And I’d get a different result of which ones passed or failed each time I clicked.

I wish I had used a screen recorder or something, I assure you it happened.

Glitch seems to do that. They’re having issues with their project rendering right now - I was having a similar error where my tests would randomly pass and fail. If you check the error message it should say (Test Timed Out).

If you run into this error again, check the status of their services.

1 Like