Class inheritance testing with mocha: getting 'ReferenceError: config is not defined' for one class but not another

Viewed 182

I am testing inheritance between two classes in js and running into errors with one class but not another. Here is the two classes and the tests I am running starting with the two classes followed by the two tests:

class BuildingModel{
    constructor(city, lastInspect){
        this._city = city;
        this._lastInspect = lastInspect;
    }

    get city() {
        return this._city;

    }

    get lastInspect() {
        return this._lastInspect;
    }
}
module.exports = {BuildingModel};




const { BuildingModel } = require('./building');

class House extends BuildingModel{
    constructor(sqFt, address, price) {
        super(city, lastInspect)
        this._sqFt = sqFt
        this._address = address
        this._price = price
    }     
, 
    get price() {
        return this._price
    }

    get address() {
        return this._address
    }

    get sqFt() {
        return this._sqFt
    }

    get city(){
        return this._city
    
    }

    get lastInspect(){
        return this._lastInspect
    }
}

module.exports = { 'House' : House,
                'BuildingModel' : BuildingModel}





const assert = require('assert');
const chai = require('chai');
const { BuildingModel } = require('../building');

const expect = chai.expect;
const assertEq = assert.deepStrictEqual


describe('Building', function () {
    describe('#constructor', function () {
        it('Building construction working!', function () {
            const city = "Fruita"
            const lastInspect = 1994
            const building = new BuildingModel(city, lastInspect)
            assertEq(building.city, city)
            assertEq(building.lastInspect, lastInspect)
        });
        it('End of building test', function () {
            // ....
        });
    });
});




const assert = require('assert');
const chai = require('chai');
const { House }  = require('../house');

const expect = chai.expect;
const assertEq = assert.deepStrictEqual

describe('House', function() {
  describe('#constructor', function() {
    it('Houses construction working!', function(){
            const price = 120000        
        const address = "123 Lane"
        const sqFt = 1200
        const house = new House(sqFt, address, price, city, lastInspect)
        assertEq(house.price, price)
        assertEq(house.address,address)
        assertEq(house.sqFt,sqFt)
    });
    it('End of house test', function(){
        // ....
    });
  });
});

I think I am really close but this is the test result I am getting:

Building #constructor √ Building construction working! √ End of building test

House #constructor 1) Houses construction working! √ End of house test

3 passing (11ms) 1 failing

  1. House #constructor Houses construction working!: ReferenceError: config is not defined at new House (house.js:5:15) at Context. (test\housetest.js:14:23) at processImmediate (internal/timers.js:461:21) npm ERR! Test failed. See above for more details.

Any help in showing me what I am doing wrong would be greatly appreciated. Thank you.

0 Answers
Related