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

TypeError: Cannot read property 'SharedIniFileCredentials' of undefined #16

Open
stevemorland opened this issue Sep 23, 2021 · 1 comment

Comments

@stevemorland
Copy link

Background

I had one small issue when integrating sls-test-tools into an integration test pack.

When running the test spec against a stack I was getting the following error:

Screenshot 2021-09-21 at 14 45 15

Background to this, previous to adding the integration test suite we had added a unit test suite with mocks for the AWS SDK following this method.

After some experimentation, it seemed the AWS Mocks file for the unit tests was being included in the integration test run, even though our route to the tests was very explicit.

Solution

The most straightforward solution was to have two jest.config.js:

  • jest.integration.config.js
  • jest.unit.config.js

In integration test config excludes the mocks:

    modulePathIgnorePatterns: [
      "__mocks__"
    ]

Then we specified which config to run in the package.json:

  "scripts": {
    "test:unit": "jest \"src/.*.test.ts\" --config=jest.unit.config.js",
    "test:integration": "jest \"__tests__/integration/.*.test.js\" --config=jest.integration.config.js"
  }

Hope this helps anyone that may run into a similar issue, or if there is a better way of dealing with this?

@valentinbeggi
Copy link
Contributor

I will add it to the documentation! Thanks :)

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