How to use miragejs - 4 common examples

To help you get started, we’ve selected a few miragejs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gitlabhq / gitlabhq / spec / frontend_integration / test_helpers / mock_server / index.js View on Github external
export const createMockServer = () => {
  const server = new Server(createMockServerOptions());

  return server;
};
github gitlabhq / gitlabhq / spec / frontend_integration / test_helpers / mock_server / index.js View on Github external
export const createMockServerOptions = () => ({
  models: {
    project: Model,
    branch: Model,
    mergeRequest: Model,
    mergeRequestChange: Model,
    mergeRequestVersion: Model,
    file: Model,
    userPermission: Model,
  },
  serializers: {
    application: RestSerializer.extend({
      root: false,
    }),
  },
  seeds(schema) {
    schema.db.loadData({
      files: getRepositoryFiles().map((path) => ({ path })),
      projects: [getProject(), getEmptyProject()],
      branches: [getBranch()],
      mergeRequests: getMergeRequests(),
      mergeRequestChanges: [getMergeRequestWithChanges()],
      mergeRequestVersions: getMergeRequestVersions(),
      filesRaw: [
        {
          raw: getBlobReadme(),
          path: 'README.md',
        },
github sanger / sequencescape / app / javascript / plate-picks / _mirage_ / index.js View on Github external
export function startMirage() {
  return new Server({
    trackRequests: true,
    environment: 'test',
    namespace: 'plate_picks',
    models: {
      plate: Model,
      batch: Model,
    },

    routes() {
      this.get('plates/:barcode', (schema, request) => {
        return schema.plates.findBy({ barcode: request.params.barcode })
      })
      this.resource('batches')
    },
  })
}

miragejs

A client-side server to help you build, test and demo your JavaScript app

MIT
Latest version published 1 year ago

Package Health Score

74 / 100
Full package analysis