Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deleting formatic wallet and fixing tests #517

Merged
merged 4 commits into from
Apr 28, 2021
Merged

deleting formatic wallet and fixing tests #517

merged 4 commits into from
Apr 28, 2021

Conversation

josojo
Copy link
Contributor

@josojo josojo commented Apr 27, 2021

closes #305

@hpmaxi
Could you plesae take a look. Somehow I don't understanding this one error message:

src/utils/index.test.ts
  ● Test suite failed to run

    TypeError: Cannot read property 'MAINNET' of undefined

      18 |
      19 | export const EASY_AUCTION_NETWORKS: { [chainId in ChainId]: string } = {
    > 20 |   [ChainId.MAINNET]: '0x0b7fFc1f4AD541A4Ed16b40D8c37f0929158D101',
         |            ^
      21 |   [ChainId.RINKEBY]: '0xC5992c0e0A3267C7F75493D0F717201E26BE35f7',
      22 |   [ChainId.XDAI]: '0x0b7fFc1f4AD541A4Ed16b40D8c37f0929158D101',
      23 | }

      at Object.<anonymous> (src/constants/index.ts:20:12)
      at Object.<anonymous> (src/utils/index.ts:11:1)
      at Object.<anonymous> (src/utils/index.test.ts:5:1)
      ~

It makes no sense to me that ChainId is undefined, although it is exported - at least in my eyes correct -.

besides this strange error message, I was able to fix all tests, such that `yarn test` would work again.

@josojo josojo requested a review from hpmaxi April 27, 2021 11:56
@github-actions
Copy link

  • 🔭 IDO UI: Easy IDO auction

@hpmaxi
Copy link
Contributor

hpmaxi commented Apr 28, 2021

@josojo

There is a problem/limitation with using enums and jest. Even using ts-jest the problem continues.

More information https://ncjamieson.com/dont-export-const-enums/
I've tried something like this, but is a big refactor.

export type ChainName = 'MAINNET' | 'RINKEBY' | 'XDAI'
export type ChainId = 1 | 4 | 100

export const ChainIds: Record<ChainName, ChainId> = {
  MAINNET: 1,
  RINKEBY: 4,
  XDAI: 100,
}

export const ChainNames: Record<ChainId, ChainName> = {
  1: 'MAINNET',
  4: 'RINKEBY',
  100: 'XDAI',
}

@josojo
Copy link
Contributor Author

josojo commented Apr 28, 2021

@josojo

There is a problem/limitation with using enums and jest. Even using ts-jest the problem continues.

More information https://ncjamieson.com/dont-export-const-enums/
I've tried something like this, but is a big refactor.

export type ChainName = 'MAINNET' | 'RINKEBY' | 'XDAI'
export type ChainId = 1 | 4 | 100

export const ChainIds: Record<ChainName, ChainId> = {
  MAINNET: 1,
  RINKEBY: 4,
  XDAI: 100,
}

export const ChainNames: Record<ChainId, ChainName> = {
  1: 'MAINNET',
  4: 'RINKEBY',
  100: 'XDAI',
}

Thanks for the input. I helped me to find a solution.

In the end, sometimes these enums are not correctly exported/imported and hence just shifting the location was already sufficient.

this one described the problem best: kulshekhar/ts-jest#1229

Copy link
Contributor

@hpmaxi hpmaxi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A great solution to the enums problem!

@josojo josojo merged commit fd9563a into develop Apr 28, 2021
@josojo josojo deleted the fixingTests branch April 28, 2021 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

broken test
2 participants