joystick
joystick copied to clipboard
Documentation: Testing
Topics that will need to be covered:
@joystick.js/cli
- [ ] Running tests with
joystick testandjoystick test --watch
@joystick.js/test
- [ ] Writing a test
- [ ] Test assertions via Ava
- [ ] Writing async tests
- [ ] Creating users
- [ ] Deleting users
- [ ] Passing users to test helpers
- [ ] Testing API endpoints (getters/setters)
- [ ] Accessing databases
- [ ] Unit testing library (/lib) functions
- [ ] Testing job definitions in queues
- [ ] Testing a component render (data, renderToHTML, method, event)
- [ ] Rendering a component
- [ ] Rendering a page component
- [ ] Rendering a layout component
- [ ] Rendering a page component within a layout component
- [ ] Testing routes
- [ ] Testing uploaders
@joystick.js/ui
- [ ] Custom function call tracking
- [ ] Tracking calls to lifecycle methods
- [ ] Tracking calls to methods
- [ ] Tracking calls to setState
- [ ] Tracking calls to CSS (if defined as a function)
- [ ] Tracking calls to data (and data.refetch)
- [ ] Tracking calls to render
@joystick.js/node
- [ ] Custom function call tracking
- [ ] Tracking calls to email.send
- [ ] Tracking calls to API endpoints (getters/setters)
- [ ] Tracking calls to API authorized function
- [ ] Testing calls to middleware
- [ ] Testing calls to websocket endpoints
- [ ] Testing calls to actions (???)
Don't forget to mention how to handle errors for various API calls (e.g., uploaders):
test.that('uploader throws error for incorrect file type', async (assert = {}) => {
const response = await test.uploaders.upload('tester', {
files: [test.utils.createFile(256, 'blah.txt', 'text/plain')],
}).catch((error) => error);
assert.is(response?.errors[0]?.message?.includes('not supported'), true);
});