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

Convert to classes and add suitenames attributes #61

Merged
merged 17 commits into from
Feb 1, 2024
Merged

Convert to classes and add suitenames attributes #61

merged 17 commits into from
Feb 1, 2024

Conversation

SimeonC
Copy link
Contributor

@SimeonC SimeonC commented Jan 19, 2024

Adding the JSDoc comments should create support for not needing individual types, at minimum this and the // @ts-check comment gives some extra typechecking without upgrading everything to typescript

Fixes #8

@davidparsson
Copy link
Owner

Brilliant, thanks! I'll try to get the review done as soon as possible.

@SimeonC
Copy link
Contributor Author

SimeonC commented Jan 31, 2024

@davidparsson sorry to bug, I've had an issue with one of our CI reporters that this would let me fix nicely this week. I was wondering if you'll have time to get to review this PR soon or I should put a temporary hack into our CI for now to workaround it. (No pressure, I can totally workaround it but I'd like to fix it nicely if possible)

@davidparsson
Copy link
Owner

@SimeonC, sorry for the delay. I'll get it done!

Copy link
Owner

@davidparsson davidparsson left a comment

Choose a reason for hiding this comment

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

Thank you very much for your contribution.

I have a few minor comments but overall it looks fine. I'll fix a few of them myself. Once we're both happy with this I'll merge it and publish a release right away.

spec/e2e_spec.js Show resolved Hide resolved
}
}

module.exports = JUnitReportBuilder;
module.exports = { Builder: JUnitReportBuilder };
Copy link
Owner

Choose a reason for hiding this comment

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

Are changes like this one completely backwards-compatible, or do they require adding curly brackets to the import statements (like this var { Builder } = require('./builder');)?

If they break backwards-compatibility, are they necessary? Best practice?

It might maybe be safe to assume that everyone uses (and can continue to use) this as the only import?

var builder = require('junit-report-builder');

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Outside of src/index.js this won't have any affect as require('junit-report-builder') get's the default export of that file, not these files I refactored, because it resolves to the main field in package.json.

Technically they are breaking changes if someone does require('junit-report-builder/src/builder') then it will break, but technically we're not supposed to do that with node_modules 😂.

That said, this is a habit of mine - doing exports like this makes sure that we use the same name everywhere or explicitly rename it.

src/builder.js Outdated Show resolved Hide resolved
src/test_case.js Outdated Show resolved Hide resolved
src/test_group.js Outdated Show resolved Hide resolved
src/test_node.js Outdated Show resolved Hide resolved
Comment on lines +33 to +38
/**
* @param {string} [message]
* @param {string} [type]
* @returns {TestCase}
* @chainable
*/
Copy link
Owner

Choose a reason for hiding this comment

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

According to what I've found, @chainable is part of JSDoc but not part of TypeScript's supported JSDoc types. What are your thoughts on that? Is that intentional? Do they still add any value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't find the Stack Overflow/Github issue where I found that. Without it I think I did have more TS errors than with it so I think it might be something undocumented, or it was caused by something else and we don't actually need it anymore.

Comment on lines +17 to +22
/**
* @param {string} name
* @param {string} value
* @returns {TestNode}
* @chainable
*/
Copy link
Owner

Choose a reason for hiding this comment

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

The type of value might be stricter than before, right? But requiring strings makes sense since we don't do any type conversions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, technically the type is stricter as all the types used to be any. It won't break any existing code as you said we don't convert/check the values but it will throw TS errors on upgrading if the user is passing a number/boolean.

src/builder.js Outdated Show resolved Hide resolved
@@ -1,43 +1,61 @@
var _ = require('lodash');
var xmlBuilder = require('xmlbuilder');
// @ts-check
Copy link
Owner

Choose a reason for hiding this comment

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

Would it be possible to run a type check for all files with @ts-check on CI somehow? It would be neat.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this can be done with typescript, but at that point may as well convert it all to typescript anyway as I don't think there's limits to the types we can define in JSDOC

@davidparsson
Copy link
Owner

@SimeonC, thanks again! I'm now happy with the current state of the PR, so I'll merge and release it now.

I'd still appreciate if you took the time to review my comments above, primarily the unresolved ones.

@davidparsson davidparsson merged commit e0bf7e2 into davidparsson:main Feb 1, 2024
16 checks passed
@SimeonC SimeonC deleted the convert-to-classes branch February 2, 2024 01:49
@SimeonC
Copy link
Contributor Author

SimeonC commented Feb 2, 2024

Thanks for cleaning up and merging! (just got back to PC this morning now)

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.

Feature request: root-level attributes for counts
2 participants