Files
Bubberstation/tgui/docs/writing-tests.md
Jeremiah 9db2f6916b Sets prettier to run on the repo (#91379)
## About The Pull Request
Prettier (an auto formatter) is set to only run within the tgui folder
currently. This removes that limitation, allowing it to automatically
format all supported files in the repo (.js, .html, .yml
[etc](https://prettier.io/docs/))

I made a few exceptions for bundled and generated files
## Why It's Good For The Game
I'm of the opinion that code should look uniform and am lazy enough to
want CTRL-S to format files without having to think beyond that
## Changelog
2025-05-29 21:23:59 -07:00

618 B

Jest

You can now write and run unit tests in tgui.

It's quite simple: create a file ending in .test.ts or .spec.ts (usually with the same filename as the file you're testing), and create a test case:

test('something', () => {
	expect('a').toBe('a');
});

Refer to README to learn how to run tests.

There is an example test in packages/common/react.spec.ts.

You can read more about Jest here: https://jestjs.io/docs/en/getting-started

Note, that there is still no real solution to test UIs for now, even though a lot of the support is here (jest + jsdom). That will come later.