Just dipping my toes into the world of Javascript and currently tackling objects and test driven development in my classes.
I've encountered a bit of trouble with my code and tests - not quite sure why they're failing. Initially, everything worked fine with just one object and its corresponding test, but adding a second object caused some issues.
Main:
const person1 = {name: "Louis"}
const person2 = {name: "Amber"}
module.exports = person1
module.exports = person2
Test Code:
const { TestScheduler } = require("jest")
const person1 = require('./family')
const person2 = require('./family')
describe('person objects', () => {
test('I am in the family', () => {
expect(person1.name).toEqual("Louis")
})
test('My sister is in the family', () => {
expect(person2.name).toEqual("Amber")
})
})
Test Outcome:
Debugger attached.
FAIL ./family.test.js
person objects
✕ I am in the family (4 ms)
✓ My sister is in the family
● person objects › I am in the family
expect(received).toEqual(expected) // deep equality
Expected: "Louis"
Received: "Amber"
5 | describe('person objects', () => {
6 | test('I am in the family', () => {
> 7 | expect(person1.name).toEqual("Louis")
| ^
8 | })
9 | test('My sister is in the family', () => {
10 | expect(person2.name).toEqual("Amber")
at Object.<anonymous> (family.test.js:7:30)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 passed, 2 total
Snapshots: 0 total
Time: 1.178 s