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

RFC: Add testing mechanism #134

Merged
merged 10 commits into from
Jul 3, 2024
Merged

RFC: Add testing mechanism #134

merged 10 commits into from
Jul 3, 2024

Conversation

72636c
Copy link
Member

@72636c 72636c commented Jun 25, 2024

I will write a changeset and tests if peeps are on board with this :)

I will write a changeset and tests if peeps are on board with this :)
@72636c 72636c requested a review from a team June 25, 2024 08:12
Copy link

changeset-bot bot commented Jun 25, 2024

🦋 Changeset detected

Latest commit: fa9dd2f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@seek/logger Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment on lines +70 to +72
const { destination, stdoutMock } = createDestination({
mock: config.environment === 'test',
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fielding opinions on this interface and the stdoutMock name in particular

Comment on lines +80 to +91
/**
* Convenience method to retrieve a solitary logging call.
*
* Throws an error if more or less than 1 call has been recorded.
*
* This may be asserted against in a test case.
*
* ```typescript
* expect(stdoutMock.onlyCall()).toMatchSnapshot();
* ```
*/
onlyCall: (): object => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we think of any other convenience methods worth implementing in a first cut?

Comment on lines +30 to +34
export const createDestination = Object.assign(
(opts: CreateDestinationOptions) => {
const stdoutMock = createStdoutMock(
typeof opts.mock === 'object' ? opts.mock : DEFAULT_MOCK_OPTIONS,
);
Copy link
Member Author

@72636c 72636c Jun 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is inherent overhead here in us initialising a stdoutMock even in production where opts.mock: false. However this should be truly negligible overhead that is only incurred once on startup.

Copy link
Contributor

@AaronMoat AaronMoat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this. Asserting log output is something that I don't do often but when I want to, it's been a giant pain.

@72636c 72636c mentioned this pull request Jul 2, 2024
@72636c 72636c requested a review from AaronMoat July 3, 2024 01:25
Copy link
Contributor

@AaronMoat AaronMoat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

@72636c 72636c merged commit 4ddb80a into master Jul 3, 2024
4 checks passed
@72636c 72636c deleted the testing branch July 3, 2024 01:46
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

Successfully merging this pull request may close these issues.

2 participants