-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Fix tests #1002
Fix tests #1002
Conversation
Wow. @UziTech, this is very impressive. Thank you so much. Given the spread of changes I would like a second pair of eyes and some questions confirmed. Maybe @Feder1co5oave, @matt-, or @KostyaTretyak can have a look. Questions/confirmation:
Again, thank you so much, this should make it much easier to do comparitive analysis and support different specs in the future. |
test/index.js
Outdated
try { | ||
fs.mkdirSync(path.resolve(__dirname, dir), 0755); | ||
fs.mkdirSync(path.resolve(__dirname, dir), 0o755); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0o755
- it's not typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is an octal literal
test/index.js
Outdated
}; | ||
})()); | ||
} catch (e) { | ||
console.log('Could not bench markdown-it.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we can show error like this: console.log('Could not bench markdown-it. (Error: %s)', e.message);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of doing something like that.
Would we want to also check for e.code === 'MODULE_NOT_FOUND'
and display a message like Please install x to run bench
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to make it simpler - just error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@UziTech: Maybe create an issue for the idea of "module not found" - I like the idea of decoupling us from packages and giving users a message like that. I'd flag it for 0.6.0 milestone as it improves the developer experience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way I set it up now if they don't have a module installed they will see:
Could not bench showdown. (Error: Cannot find module 'showdown')
|
All right. LGTM! Easy to change in future without affecting our users...rollback or something else. And confirmed...way to come together. Again, awesome work. Thank you. |
I recently peeked into the test script and I must say it looks hacky as hell. The For instance, one of the features that marked has is automatic id generation for headings, which look quite cumbersome (and painful to hand-write) in test cases. Should we consider disabling this in testing? |
@Feder1co5oave, do you mean this method? Renderer.prototype.heading = function(text, level, raw) {
return '<h'
+ level
+ ' id="'
+ this.options.headerPrefix
+ raw.toLowerCase().replace(/[^\w]+/g, '-')
+ '">'
+ text
+ '</h'
+ level
+ '>\n';
}; It would be better? Renderer.prototype.heading = function(text, level, raw) {
var id = this.options.headerPrefix + raw.toLowerCase().replace(/[^\w]+/g, '-');
return `<h${level} id="${id}">${text}</h${level}>\n`;
}; |
As for me, |
No, I meant Spaces are too tricky to make sure they match perfectly. |
I have rewritten test-script in myself:
|
Throwing copper... I believe we're using a sort of homegrown solution for testing, yeah? I don't see JSUnit, for example, as a dev dependency. Writing code to solve our specific problem is great, but might be nice for other developers to not have to learn some new way to write tests as well. |
I don't think unit testing is suitable for this. The current testing concept (input-vs-expected-output) is the right one, it just needs to be more homogeneous. |
I thought about moving to a modern testing framework (jasmine, mocha, etc.) when rewriting the tests but I agree with @Feder1co5oave. The input output approach is much easier than writing unit tests with fixtures. We could add some sort of unit tests on top of the current test to provide more control. At the moment there is no way to run a test that changes the options in between tests without writing multiple tests. |
Just to deal with the language thing to make sure I'm on the same page with y'all. I tend to lump tests into three groups: unit, integration, and application. Unit: Testable in isolation of a single function or class to confirm input-output. In my brain, we'd being doing more of an integration test - I'm with y'all - not concerned the parts in isolation (sorry if the JSUnit mention got us on the "unit" testing thing). Want to verify we get the desired output based on a specific input. Doesn't mean we can't use a more standard testing library see 8fold Component: https://github.com/8fold/php-html-component/blob/master/tests/ComponentTest.php The only issue from a developer experience perspective, would be in the markdown versus HTML files. But, I defer to @UziTech more than anyone, because he seems the most familiar and I don't have the bandwidth to dive too deep on things. (Thanks again, y'all have been a pleasure to work with.) |
All right. LGTM! Easy to change in future without affecting our users...rollback or something else. And confirmed. Again, awesome work. Thank you.
Changes to tests
.md
files instead of.text
--fix
the tests as it is done automatically before you run the tests--no-fix
arg for the tests in case you don't want it to automatically fix the tests before testing.md
file to specify the options instead of the file namefixes #998