aleios-cloud / aleios-cloud/sls-test-tools

TypeError: Cannot read property 'SharedIniFileCredentials' of undefined

Đang mở
#16 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
195
Fork
20
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

## 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](https://dev.to/elthrasher/mocking-aws-with-jest-and-typescript-199i).

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:

```Javascript
modulePathIgnorePatterns: [
"__mocks__"
]
```
Then we specified which config to run in the `package.json`:

```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?

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.