1.2.1 • Published 1 year ago

@comparaonline/test-helpers v1.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Test-helpers

Notes

  • describeRecording default config path is process.cwd() + /src/test/cassettes/
  • Overwrite default config should be done using setupFilesAfterEnv on jest.config.js

Configs

API

Config nametypedefault
defaultPathstring'src/test/cassettes'
useProcessCwdbooleantrue
createPathbooleantrue

Overwrite

import { setConfig, ConfigName } from '@comparaonline/test-helpers';

setConfig(ConfigName.DefaultPath, 'src/test/cassettes');
setConfig(ConfigName.UseProcessCwd, true);
setConfig(ConfigName.CreatePath, true);

Examples

Using describeRecording

// my-test.test.ts
import { describeRecording } from '@comparaonline/test-helpers';

const CASSETTES_PATH = 'first-test';

describe('My test with mock', () => {
  describeRecording(
    'My http test',
    () => {
      it('Should connect with something http', async () => {
        // do something
      });
    },
    CASSETTES_PATH
  );

  // After the first this will create /src/test/cassettes/first-test/my-test.my-http-rest.json
});

Generate testServer const/function

import { testServerGenerator } from '@comparaonline/test-helpers';
import { router } from './event-server/router'; // Change this route to your event-server/router

export const testServer = testServerGenerator(router);
1.2.1

1 year ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago