Open EHadoux opened 1 month ago
Hey, can you provide a repro details when you encounter this issue?
I saw the same behaviour and I have resolved this issue by installing chalk 5.3.0
(just latest at the time) as a dev dependency of my project (not ideal).
I can see that chalk
is installed in the jest matcher package as a devDependency, is that intentional? It isn't being declared as a dependency of the installed package which maybe it should be? And if there is another version of chalk
around (I think that was where my issue was) unexpected behaviour like this issue describes might be seen.
i just ran into this issue as well and agree that making chalk
a prod dependency instead of a dev-dependency is the correct fix if the use of chalk is needed there
Yeah sorry, my initial post could have been better. The solution is indeed to have the latest version of chalk and not to change the code to comply with a previous version as suggested in my initial post.
I am also facing this problem as well so created a pr to move chalk as a dependency instead of a dev dependency @m-radzikowski if you could take a look that would be great
Same issue here today. For now have installed chalk 5.3.0
as a dev dependency in my project. Unfortunately that did not solve the problem for me.
import 'aws-sdk-client-mock-jest/vitest';
import { mockClient } from 'aws-sdk-client-mock';
import { beforeEach, describe, expect, test } from 'vitest';
import { DynamoDBDocumentClient, PutCommand, QueryCommand } from '@aws-sdk/lib-dynamodb';
import { recordCodeSentHistory } from '../../src/login-codes/code-history';
describe('tests', () => {
const ddbMock = mockClient(DynamoDBDocumentClient);
beforeEach(() => {
ddbMock.reset();
});
test('it should record login code history in dynamodb', async () => {
ddbMock.on(PutCommand).resolves({});
await recordCodeSentHistory('dynamo_table', 'joe@bloggs.com', 2);
expect(true).toBeTruthy();
});
});
FAIL functions/cognito-create-auth-challenge/test/login-codes/code-history.test.ts [ functions/cognito-create-auth-challenge/test/login-codes/code-history.test.ts ]
TypeError: Chalk is not a constructor
❯ node_modules/aws-sdk-client-mock-jest/src/vitest.ts:23:5
❯ functions/cognito-create-auth-challenge/test/login-codes/code-history.test.ts:1:1
1| import 'aws-sdk-client-mock-jest/vitest';
| ^
2| import { mockClient } from 'aws-sdk-client-mock';
3| import { beforeEach, describe, expect, test } from 'vitest';
I've tried importing in different orders and re-installing node_modules with no success.
Would be great to get this PR merged to remove the issue.
Looks like this line is problematic:
https://github.com/m-radzikowski/aws-sdk-client-mock/blob/3981b97a249a05610f8751d86a5c3428959f0112/packages/aws-sdk-client-mock-jest/src/vitest.ts#L18
aws-sdk-client-mock: 4.1.0 aws-sdk-client-mock-jest: 4.1.0
Replacing with:
seems to fix it. I can open a PR if you're happy with this change 👍