Skip to content

Bug: Incorrect Mocking Behavior for Arrays (fixed values) #76

@omermorad

Description

@omermorad

Description:
There is a bug when using the mock method to mock a fixed/primitive value of type array. When attempting to mock a dependency with an array value using the using method, the expected behavior doesn't match the actual outcome. The issue seems to be specific to array values, as other fixed/primitive values of different types are correctly mocked.

Steps to Reproduce:

  1. Create a class with a dependency that has an array type.

  2. Attempt to mock the array dependency using mock and using methods as shown below:

    class SomeClass {
      public constructor(@Inject('ARRAY_TYPE') private readonly someArray: string[]) {}
    }
    
    const { unit, unitRef } = TestBed.create(SomeClass)
      .mock('ARRAY_TYPE')
      .using(['1', '2', '3'])
      .compile();
  3. Observe the result of the mocked array dependency.

Expected Behavior:
The array dependency should be successfully mocked with the provided array value.

Actual Behavior:
The array dependency is not correctly mocked, and the provided array value is not set as the dependency.

Environment:

  • Automock Version: @automock/jest@1.2.3

Additional Information:
I suspect that the issue might be related to how Automock handles array values in the using method. Other fixed/primitive values are correctly set as dependencies, but arrays seem to be affected by this bug.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions