You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm struggling with setting up unit tests that depend on Screeps types.
For example, when trying to extend Creeps like this:
Creep.prototype.someFunction = ...
My IDE is happy, the compiled code runs in game just fine, all types are resolved. But, when executing a unit test that imports the above code, it always fails with
ReferenceError: Creep is not defined
How to teach ts-jest to look at the right place and resolve Creep and other types located in node_modules/@types/screeps/index.d.ts ?
Thank you in advance!
The text was updated successfully, but these errors were encountered:
stkiller
changed the title
Question - how to make ts-jest happy at runtime?
Question - how to make ts-jest happy at test runtime?
Jul 26, 2021
Below is based on my own understanding, take with a grain of salt.
Anything found in *.d.ts is just a declaration to help your IDE and TypeScript figure out if the code is wrong. None of these types are available at runtime.
Hello there!
I'm struggling with setting up unit tests that depend on Screeps types.
For example, when trying to extend Creeps like this:
My IDE is happy, the compiled code runs in game just fine, all types are resolved. But, when executing a unit test that imports the above code, it always fails with
How to teach ts-jest to look at the right place and resolve
Creep
and other types located innode_modules/@types/screeps/index.d.ts
?Thank you in advance!
The text was updated successfully, but these errors were encountered: