IsaacScript / isaacscript

IsaacScript is a tool to help you create Binding of Isaac: Repentance mods using TypeScript.

Home Page:https://isaacscript.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Export definitions' JS files for the test support

aleksander-ciesielski opened this issue · comments

Currently, there are only .lua files exported, making testing impossible as e.g., jest will only accept the .js files.

Simple npx tsc in the build.sh won't do, as the code is dependent on some existing Lua code, like BitSet128 function - the best option is to also create a custom jest environment as another npm package, that would include all the required polyfills.

commented

what's the motivation here? to run jest in CI and just detect errors sooner?

I would like to unit test my mod by mocking the game state and testing my code's logic, which is currently impossible as enums don't exist when the jest runs.

commented

i dont see a problem with the proposal, can you submit a PR?

I could, but what do you think about a custom Jest environment as a separate package? Like isaacscript-jest-environment? Is it too opinionated, as it only targets Jest?

commented

I could, but what do you think about a custom Jest environment as a separate package?

seems fine.
but we would still need isaac-typescript-definitions to export js files ultimately like your OP suggests, right?

Is it too opinionated, as it only targets Jest?

jest is the current testing leader in js/ts, so im fine with that opinion

Yes, it requires both exporting JS files to make using it with a JavaScript runtime possible, and to include polyfills for the Lua-specific code (preferably in the form of the Jest environment).