joystick icon indicating copy to clipboard operation
joystick copied to clipboard

Documentation: Testing

Open rglover opened this issue 2 years ago • 1 comments

Topics that will need to be covered:

@joystick.js/cli

  • [ ] Running tests with joystick test and joystick 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 (???)

rglover avatar Aug 24 '23 18:08 rglover

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);
});

rglover avatar Aug 25 '23 19:08 rglover