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

When using withDb at the top of a test file test.concurrent seem to execute before tables are available. #92

Open
kitsunde opened this issue Jul 5, 2023 · 1 comment

Comments

@kitsunde
Copy link

kitsunde commented Jul 5, 2023

Hello,

I setup jest in each test file, but his an issue where in test.concurrent the table doesn't seem to exist:

require('jest-dynalite/withDb');

const { DynamoDB } = require('aws-sdk');

const client = new DynamoDB({
  ...(process.env.MOCK_DYNAMODB_ENDPOINT && {
    endpoint: process.env.MOCK_DYNAMODB_ENDPOINT,
    sslEnabled: false,
    region: 'local',
  }),
});

describe('dynalite', () => {
  test.concurrent('will contain tables concurrent', async () => {
    const tables = await client.listTables().promise();

    expect(tables.TableNames.length).toEqual(1);
  });

  test('will contain tables not concurrnet', async () => {
    const tables = await client.listTables().promise();

    expect(tables.TableNames.length).toEqual(1);
  });
});

This is when it's used with a setupBeforeEnv.js:

const { setup } = require('jest-dynalite');

setup(__dirname);

However if I switch to preset: 'jest-dynalite' both modes work.

@freshollie
Copy link
Owner

To use concurrent you are gonna need to manually start and stop the DB. The default behaviour removes the tables and recreates them between each test, which I imagine doesn't work with concurrency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants