question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

mock set to null when interface and namespace have the same name

See original GitHub issue

Subject of the issue

When there is a namespace and an interface with the same name, with the namespace declared first, mocking that interface returns null.

Your environment

  • ts-auto-mock version: 3.2.2
  • typescript version: 4.3.2
  • node version: 14.3.0
  • npm version: 7.6.0
  • list any other dependencies that you think are relevant
    • though it is probably irrelevant to the example, I am using jest-ts-auto-mock v2.0.0

Steps to reproduce

import {createMock} from 'ts-auto-mock'
namespace B {}
interface B {
  b: string
}
console.log(createMock<B>())

Expected behavior

Should log {b: ""}

Actual behavior

Actually logs null

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Pmylcommented, Jun 17, 2021

PR open to fix it #793 now waiting for @uittorio to review it, in one day max it should go in 😄

1reaction
Pmylcommented, Jun 17, 2021

I confirmed the bug, I’ll take care of it!

The last thing you said is normal, for the transformer B is an empty object so that generates an empty object (plus a marker for mocks to work that won’t impact any runtime execution)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mocked method returns null - Stack Overflow
The Mock would return a default value (e.g. null) in case a call is made for which an expectation has not been set....
Read more >
JUnit 5 User Guide
Used to configure the test instance lifecycle for the annotated test class. Such annotations are inherited. @DisplayName. Declares a custom ...
Read more >
Testing Reference | GoogleTest
Tests in different test suites can have the same individual name. The statements within the test body can be any code under test....
Read more >
Using xUnit to Test your C# Code - Auth0
How to create unit tests and integration tests with xUnit for your C# applications.
Read more >
Why do I get an error "value cannot be null (Parameter 'type ...
namespace CoreMVC5Sample.Models; {; public class Locations; {; public Locations(); {; Name = "default";; }; public string Name { get; set; } ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found