Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
Internal: add "actual" test output files to make diff easier
Browse files Browse the repository at this point in the history
  • Loading branch information
MoOx committed Mar 12, 2016
1 parent b7fe686 commit 4d3266a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules
# build
lib
docs/dist
src/__tests__/fixtures/**/*.actual.css
10 changes: 7 additions & 3 deletions src/__tests__/option.features.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const testFeature = function(
feature,
source,
input,
expected
expected,
slug
) {
const options = { features: { } }

Expand All @@ -40,8 +41,11 @@ const testFeature = function(
// enable only the one we want to test...
options.features[feature] = true

const actual = cssnext(options).process(input).css.trim()
utils.write(utils.fixturePath(join("features", slug + ".actual")), actual)

t.equal(
cssnext(options).process(input).css.trim(),
actual,
expected.trim(),
"should add " + feature + " support"
)
Expand All @@ -54,7 +58,7 @@ Object.keys(features).forEach(function(name) {
const expected = utils.readFixture(join("features", slug + ".expected"))

test(slug, function(t) {
testFeature(t, name, source, input, expected)
testFeature(t, name, source, input, expected, slug)

t.end()
})
Expand Down
10 changes: 10 additions & 0 deletions src/__tests__/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,14 @@ export default {
readFixture(name, ext) {
return fs.readFileSync(this.fixturePath(name, ext), "utf8")
},

/**
* read a fixture
* @param {String} name
* @param {String} ext (optional extension, default to ".css")
* @return the fixture content
*/
write(name, content) {
return fs.writeFileSync(name, content)
},
}

0 comments on commit 4d3266a

Please sign in to comment.