Skip to content

Update tests to match the testing guidelines #62

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

gasperzgonec
Copy link
Contributor

Summary

Updated tests to match the testing guidelines specified inside of CONTRIBUTING.md file.
I have changed how the testing works.

Before, we had npm run test, which ran all tests, including timeout tests, which took quite a while. I've removed them from the default testing and removed the coverage as well.

Full and coverage tests include timeout tests and can be accessed using test:full and test:cov. The actions should use test:cov by default and work as before.
This speeds up testing a lot (3.5s vs 26s).

Connected Issues

@gasperzgonec gasperzgonec force-pushed the gasperz/ISS-202839 branch 2 times, most recently from b28272a to b6838fe Compare August 22, 2025 08:42
Copy link
Contributor

@patricijabrecko patricijabrecko left a comment

Choose a reason for hiding this comment

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

Let's also use ClassName.function.name if that's possible, otherwise looks good 👍

@@ -75,7 +75,6 @@ describe('WorkerAdapter', () => {

describe('streamAttachments', () => {
it('should process all artifact batches successfully', async () => {
// Arrange
Copy link
Contributor

Choose a reason for hiding this comment

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

This is about line 76:
We can use WorkerAdapter.streamAttachments.name

Copy link
Collaborator

@radovanjorgic radovanjorgic left a comment

Choose a reason for hiding this comment

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

Few suggestions, questions

testPathIgnorePatterns: [
'./dist/',
// Exclude timeout tests by default - they should only run with test:full or test:cov
'./src/tests/timeout-handling/'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I have just checked and tests last ~20s longer when we don't ignore timeout-handling. I suggest not ignoring them, we have them for purpose and this can easily tell us if we broke something. Also these are only "e2e" tests we currently have.

Comment on lines +14 to +16
"test": "jest --silent --verbose=false",
"test:full": "jest --forceExit --runInBand --testPathIgnorePatterns='./dist/' --silent --verbose=false",
"test:cov": "jest --forceExit --coverage --runInBand --testPathIgnorePatterns='./dist/' --silent --verbose=false"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you are "over-engineering" this a bit. For simplicity, can we keep test as main script that will be mostly used (in CI and by developers) and remove others if not useful/needed. TBH I am used to often run npm run build and npm run test checks locally while developing.

@@ -35,7 +35,7 @@ jobs:
run: npm ci

- name: Run tests and get coverage
run: npm run test
run: npm run test:cov
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you remove this script please fix this too.

@@ -11,7 +11,9 @@
"start": "ts-node src/index.ts",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"test": "jest --forceExit --coverage --runInBand"
"test": "jest --silent --verbose=false",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, --silent flag can be a bit tricky, since it hides logs for all tests (even the failed ones) and if something breaks on CI it is hard to figure out what without logs. We need to fix existing tests to not log a lot of noise (we can't do anything for logs coming from SDK - logs like emitting events and similar).

@@ -11,7 +11,9 @@
"start": "ts-node src/index.ts",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"test": "jest --forceExit --coverage --runInBand"
"test": "jest --silent --verbose=false",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't --verbose=false by default?

@@ -66,7 +66,7 @@ describe('AttachmentsStreamingPool', () => {
jest.restoreAllMocks();
});

describe('constructor', () => {
describe(AttachmentsStreamingPool.prototype.constructor.name, () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe it won't be a bad idea to add how we should name these describe blocks in tests. Sometimes you can just use functionName.name or ClassName.method.name, but in some cases you need .prototype.name. Can we at least write down that these values ideally (if possible and makes sense) shouldn't be hardcoded?

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.

3 participants