Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A better way to modify of config between test #23

Open
alallema opened this issue Oct 12, 2021 · 1 comment
Open

A better way to modify of config between test #23

alallema opened this issue Oct 12, 2021 · 1 comment

Comments

@alallema
Copy link
Contributor

Currently, in __tests__/utils.test.ts, here the way to mock the config data and test the functions getSearchableFields in every tests:

  test('return list with one field', () => {
    restoreEnv = mockedEnv({ ...environment, SEARCHABLE_FIELDS: 'field' })
    const util = require('../src/util')
    mockGetSearchableFields = util.getSearchableFields()
    expect(mockGetSearchableFields).toMatchObject(['field'])
  })

It would be better to be able to mock the config just once and not in every test.

@bidoubiwa
Copy link
Contributor

This should be do-able using the module mocking from jest, for the mocking of Meilisearch and the setup file in jest (example: jest setup and setup script).

@bidoubiwa bidoubiwa added good first issue Good for newcomers hacktoberfest and removed good first issue Good for newcomers labels Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants