I manage a factory that specializes in facilitating dependency injection. Here's an example of what it looks like:
import SomeImportantObject from "./SomeImportantObject"
import DataInterface from "./DataInterface"
class NoodleFactory {
this.dependency: SomeImportantObject
constructor(dependency: SomeImportantObject) {
// Setting up dependencies.
this.dependency = dependency;
}
create(data: DataInterface) {
return new Noodle(data, this.dependency);
}
}
Recently, as part of ensuring the correctness of the factory in creating objects, I developed a test that closely resembles the following:
data = {
// Sample data.
}
mockDependency = "a mocked dependency."
testNoodleFactory = new NoodleFactory(mockDependency);
const expected = new Noodle(data, mockDependency);
const actual = testNoodleFactory.create(data);
test("Confirming noodle creation by the factory", () => {
expect(actual).toMatchObject(expected);
});
However, upon running the test, an error message appears:
@@ -1,6 +1,6 @@
- Noodle {
+ Object {
All internal data seems to be aligned correctly.
What might be causing the discrepancy in object types?