Closed gilkeidar closed 1 year ago
Task Description: Add Jest unit tests to the Cartomancy mini-app.
tests
cartomancy
cartomancy.test.js
Note: You cannot call fetch() in Jest unit tests. This includes testing whether a JSON file was read correctly by the FortuneEngine.
fetch()
FortuneEngine
If you want to test a feature that relies on the FortuneEngine, do the following:
// Create a FortuneEngine object const engine = new FortuneEngine('Test'); // Can't test fetch() in Jest - assume read. engine.initialized = true; // Set JSON contents const jsonContents = { // insert your JSON file's contents here }; engine.json_contents = jsonContents; const outcomes = engine.json_contents['option-result pair']; engine.outcomes = outcomes; // can safely call get_random_subset() now
Is it gross? Yes. But Jest is made for unit testing - I believe we need end-to-end testing support to facilitate testing of this kind.
Task Description: Add Jest unit tests to the Cartomancy mini-app.
tests
directory, create the subdirectorycartomancy
.cartomancy.test.js
)Note: You cannot call
fetch()
in Jest unit tests. This includes testing whether a JSON file was read correctly by theFortuneEngine
.If you want to test a feature that relies on the
FortuneEngine
, do the following:Is it gross? Yes. But Jest is made for unit testing - I believe we need end-to-end testing support to facilitate testing of this kind.