bitburner-src/test/jest
David Walker 06553d9700
BUGFIX: Fix "Router called before initialization" race (#1474)
If the game takes long enough to load, certain counters can become
eligible to run as soon as Engine.start() runs. When this happens,
eventually Router.page() is called, which throws an Error since Router
isn't initialized yet. (Dropping a breakpoint before Engine.start() and
waiting at least 30 seconds is enough to reliably repro, but I have seen
this both live and in tests.)

This fixes it so that Router.page() is valid immediately, returning a
value of Page.LoadingScreen. It also removes the isInitialized field,
since this is now redundant. Trying to switch pages is still an error,
but that doesn't happen without user input, whereas checking the current
page is quite common.

This also consolidates a check for "should we show toasts" behind a
function in Router, making the logic central and equal for a few
usecases. This means (for instance) that the "autosave is disabled"
logic won't run during infiltration. (The toast should have already been
suppressed.)
2024-07-07 22:13:37 -07:00
..
__snapshots__ IPVGO: Support bonus cycles from offline time (#1345) 2024-06-04 18:43:29 -07:00
Alias TERMINAL: Prevent recursive aliases from being resolved. (#741) 2023-08-28 14:26:25 -04:00
Go IPVGO: Balance and improvements for offline bonus time cycles (#1356) 2024-06-05 19:39:22 -07:00
Imports Moved Player initialization point (#452) 2023-03-29 00:30:27 -04:00
Messages BUGFIX: Fix "Router called before initialization" race (#1474) 2024-07-07 22:13:37 -07:00
Netscript EDITOR: Use ramOverride() to set compiled script RAM (#1446) 2024-07-05 17:32:46 -07:00
Script Fix test 2023-05-28 05:43:09 -04:00
Terminal v2.4.0 2023-07-30 22:08:36 -04:00
ui UI: Added new locale-aware and configurable number formatting (#354) 2023-02-11 13:18:50 -05:00
Corporation.test.ts CORPORATION: Rename functions in Actions.ts (#1272) 2024-05-12 14:52:07 -07:00
FullSave.test.ts MISC: Refactor favor code (#1321) 2024-05-28 12:04:16 -07:00
Grow.test.ts TESTS: Prevent some test spam (#1126) 2024-02-26 08:22:33 -05:00
README.md Move cypress & netscript tests to ./test subfolder 2022-01-26 05:35:21 -05:00
Save.test.ts UI: fix scripts recorded offline income (#1025) 2024-02-10 07:24:55 -05:00
StockMarket.test.ts EDITOR: Provide type definitions for React and ReactDOM in in-game editor. (#1458) 2024-07-07 00:08:33 -07:00
StringHelperFunctions.test.ts fix: fix StringHelperFunctions test 2022-09-23 18:13:33 -04:00

Unit Tests

This directory contains unit tests for Bitburner.

Unit tests use jest.

Running

Run tests with: npm run test

To watch for changes: npm run test:watch