-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
Feature Request: Support for intended fail-scenario #146
Comments
There is no way to build this into True's testing-syntax directly, since the The best we could do is provide those functions/mixins as a plugin that you can include in your primary Sass, rather than copy-pasting the functions yourself. That should be doable. In the meantime, feel free to copy/paste, and let me know if you have questions. |
Thanks! I will look into implementing in our next sprint. |
Would you consider allowing special comments to wrap around tests which should throw? Tests might be written like this: @include describe('some-mixin') {
@include it('should work') {
/* normal test omitted for brevity */
}
/** START_EXPECT_ERROR: Maybe the expected error message could go here */
@include some-mixin(bad, params);
/** END_EXPECT_ERROR */
} You would then have a multi-phase parse:
I would gladly help with this if this seems like a viable solution. My main objective is to allow people to write SASS and not have to learn a separate error mixin and global variables. Thanks again for such a wonderful tool. |
@DesignByOnyx I'm open to discussing something like that. While it requires less change to your project code (no special mixin), it also removes the ability to run your tests in pure Sass. I wonder if we could work around that by doing something like (pseudo-sass): // - regex should work just as well with a mixin, so we don't add a completely new syntax
// - by default, it won't compile. Users or True can pass in $compile: true when it should
// - if a message is given, error message must match
// - if no message is given, any error will pass the test
@mixin assert-error(
$message: null,
$compile: false
) {
/* we can supply the necessary output comments here… */
@if $compile {
@content;
} @else {
/* whatever output we want for pure-Sass compilation */
}
}
// usage…
@include assert-error(`<optional error message>`) {
/* code-block that should error */
}
// also handle warnings?
@include assert-warn(`<optional warning message>`) {
/* code-block that should warn */
} |
Would |
Yep, exactly.
Yeah, Nex3 asked me if it would be useful, and I pointed her to our current ugly workaround as the clear use-case. Not sure what will come of it, but agree we shouldn't count on it any time soon. Next Steps: Do you want to work on a PR for the entire thing? Or helpful for me to start some of the Sass end? Up to you. |
If you can give some pointers on where to start, I'd appreciate it as it would save me some time. The biggest unknown to me is how to figure out the $not-a-color: #gggggg;
@include describe('some-mixin') {
@include it('should work') {
/* normal test omitted for brevity */
}
@include it('should fail on bad params') {
@include assert-error('Must pass a valid color value') {
@include some-mixin($not-a-color);
}
}
}
|
I can stub out the Sass in a branch so you have a real sample to work from. I think the JS currently works by parsing that CSS output, so:
|
I've been digging through the code I think I figured out a good strategy for this and am going to take a stab at it. Feel free to save your time on stubbing things for right now as I think what I'm doing should work well and not require any difficult parsing. |
I would like a way to verify a fail scenario to insure code properly messages invalid parameters.
For example:
Test:
Today when I attempt a test like this, I get the fail-message in the terminal, however, the test itself fails and my other tests don't run.
The text was updated successfully, but these errors were encountered: