eventual icon indicating copy to clipboard operation
eventual copied to clipboard

Bug: Test Env fails when the output path does not have access to @eventual/core

Open thantos opened this issue 2 years ago • 2 comments

When the ourDir does not have access to @eventual/core, the test env will fail to import the bundled service code.

The tests do not currently bundle the the @eventual/* packages in, intending to use the copy that the test is using to being closer to the test.

Looks like the test env should just bundle and let their be two copies for now.

thantos avatar Jan 16 '23 20:01 thantos

Bundling all dependencies breaks mocking.

For example, if I try to mock sqs, it will mock the instance imported by the tests, and not the bundled one in the test service.

jest.mock("@aws-sdk/client-sqs", () => {
  return {
    ...(jest.requireActual("@aws-sdk/client-sqs") as any),
    SQSClient: jest
      .fn()
      .mockImplementation(() => ({ send: fakeSqsClientSend })),
  };
});

thantos avatar Jan 16 '23 20:01 thantos

For now, the service file bundled by the tests MUST be able to find the node_modules of the test workflow.

  env = new TestEnvironment({
    entry: path.resolve(
      url.fileURLToPath(new URL(".", import.meta.url)),
      "./workflow.ts"
    ),
    outDir: path.resolve(
      url.fileURLToPath(new URL(".", import.meta.url)),
      ".eventual"
    ),
  });

thantos avatar Jan 16 '23 20:01 thantos