Add sass tests too#842
Conversation
|
Oh, and if you have another idea how to implement this; I went with the environment variable solution. |
| @@ -1,5 +1,5 @@ | |||
| $blue: #3bbfce; | |||
| $margin: 16px; | |||
| $blue: #3bbfce | |||
There was a problem hiding this comment.
dart sass threw an error for indented syntax with semicolons
| stream.on('data', (cssFile) => { | ||
| assert.ok(cssFile.sourceMap); | ||
| assert.deepEqual(cssFile.sourceMap.sources, expectedSources); | ||
| assert.deepEqual(cssFile.sourceMap.sources.sort(), expectedSources.sort()); |
There was a problem hiding this comment.
I had to use sort() since dart sass and node-sass produce arrays with different sorting.
| 'inheritance.scss', | ||
| ]; | ||
|
|
||
| if (COMPILER === 'sass') expectedSourcesAfter.push('inheritance.css'); |
There was a problem hiding this comment.
This makes me wonder if something else is wrong... Dart sass includes the dist file while node-sass doesn't.
There was a problem hiding this comment.
Source maps are not part of the sass language spec and there are difference between engines. It's likely node-sass is wrong in this case. A more resilient approach might be to check for the intersection of the sources rather than a matching setting.
There was a problem hiding this comment.
Feel free to push your suggestion if you want otherwise let's land it as is.
| const stream = sass(); | ||
|
|
||
| stream.on('error', (err) => { | ||
| // Error must include message body |
There was a problem hiding this comment.
We use this style because error message formats are not part of the sass language spec and change over time. This style is more resilient to compiler changes as it simple asserts for key phrases.
There was a problem hiding this comment.
Yeah, but it's more troublesome to keep them in sync. For example, how should I test for the line with dart sass? Just check for number 2?
There was a problem hiding this comment.
I'd opt for simply removing the line number assertion. This is more the concern of the engine. All we really care about is that an error was produced.
There was a problem hiding this comment.
Please check now, it should be what you want. The line is still checked in another test, not sure if we should remove that too.
| "mocha": "mocha", | ||
| "test": "mocha" | ||
| "test": "npm run test:node-sass && npm run test:dart-sass", | ||
| "test:node-sass": "mocha", |
There was a problem hiding this comment.
Let me know if you want different script names here.
package.json
Outdated
| "test": "mocha" | ||
| "test": "npm run test:node-sass && npm run test:dart-sass", | ||
| "test:node-sass": "mocha", | ||
| "test:dart-sass": "cross-env SASS_COMPILER=sass mocha" |
There was a problem hiding this comment.
Out of curiosity could you do something like mocha -- sass and pull the compiler off of argv instead of introducing cross-env?
There was a problem hiding this comment.
It could probably work (not mocha -- sass but mocha -- --sass, but seems more hacky from a quick look. Feel free to tweak it, though.
There was a problem hiding this comment.
Actually, wait. Let me try something.
There was a problem hiding this comment.
I pushed a patch which does work but still seems hacky, but correct me if I'm wrong. Aren't we abusing the fact that mocha doesn't throw on unknown command line options?
There was a problem hiding this comment.
I'm fine with it until it's a problem :)
|
@xzyfer how about releasing a new minor version? We've landed plenty of changes and personally I don't have any further ones. :) EDIT: apart from #286 (comment) but I'm not sure it's still an issue anyway. |
|
v5.1.0 has been released |
@xzyfer I think it's worth having this. That being said, I noticed a few differences while working on this patch. This one makes me wonder:
https://github.com/dlmanning/gulp-sass/pull/842/files#diff-5a684c173d69bcc8d9e0e4b50ac83d8eaf640dbd8e141c14d9e1a953c87afbd3R482