@eyedea/syncano-test
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

@eyedea/syncano-test

Test solution for syncano socket based on @eyedea/syncano.

npm version license

Install

Install package in your socket directory:

$ npm install -D @eyedea/syncano-test

It is recommended to install this package as dev dependency, otherwise a lot of unnecessary packages will be deployed with socket.

Usage

  1. Create __tests__ directory in your socket. Add __tests__/tsconfig.json with the following content:
{
  "compilerOptions": {
    "lib": ["ES2015"]
  }
}
  1. Create your test file __tests__/ENDPOINT-NAME.test.js
import {run, stub, createSyncanoCoreMock} from '@eyedea/syncano'

describe('SOCKET/ENDPOINT-NAME', () => {
  it('should not fail', async () => {
    const meta = {user: undefined}
    const args = {id: 1}
    const mocks = createSyncanoCoreMock({
      data: {
        entity: {
          create: stub().resolves(args)
          fields: stub().fn({
            with: stub().fn({
              findOrFail: stub().resolves(args)
            })
          })
        }
      }
    })
    const result = await run('ENDPOINT-NAME', {args, meta}, {mocks})
    expect(result).toHaveProperty('data.id', args.id)
    expect(result).toHaveProperty('code', 200)
  })
})

License

MIT © Eyedea AS

Package Sidebar

Install

npm i @eyedea/syncano-test

Weekly Downloads

0

Version

0.2.0

License

MIT

Unpacked Size

9.54 kB

Total Files

19

Last publish

Collaborators

  • amroz123
  • mkucharz
  • qk
  • idered
  • hzub