dsherret / ts-nameof

nameof in TypeScript
MIT License
493 stars 23 forks source link

Appears to not work with jest@27.0.6: ReferenceError: nameof is not defined #119

Open andrewkolos opened 3 years ago

andrewkolos commented 3 years ago

Demo Repo

There are two modules, older-dependencies and up-to-date-dependencies. Both are identical except for the versions of certain dependencies including jest, ts-jest, and ts-nameof. However, running npm t in up-to-date-dependencies fails:

> jest

 FAIL  test/foo.test.ts
  ● Test suite failed to run

    ReferenceError: nameof is not defined

      1 | import foo from '../../foo';
      2 |
    > 3 | describe(nameof(foo), () => {
        | ^
      4 |   it('passes', () => {
      5 |     expect(true).toBe(true)
      6 |   })

      at Object.<anonymous> (test/foo.test.ts:3:1)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        3.652 s
Ran all test suites.
npm ERR! Test failed.  See above for more details.

However, tests work perfectly when ran in older-dependencies. Both use the setup mentioned here..

Node v: v14.15.1. OS: Windows.

RimApp commented 3 years ago

Hi,

I got the same issue "nameof is not defined". "typescript": "^4.3.4", "ts-nameof": "^4.2.2", "@types/ts-nameof": "^4.2.1", "ttypescript": "^1.5.12" Setup mentioned here.

Any solution ?