-
Notifications
You must be signed in to change notification settings - Fork 34
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
test: use snapshot and split into multiple files #143
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0c7643b
test: use snapshot and split into multiple files
marcalexiei 7980308
chore(deps-dev): update ava, @ava/typescript and nyc
marcalexiei f74a07f
test(insertStyle): replace jsdom with happy-dom
marcalexiei 8a43815
test(watchList): simplify logic
marcalexiei 36c02c2
test(options.output): add information about why we can’t use snapshot
marcalexiei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.DS_Store | ||
.idea/ | ||
.vscode/ | ||
.nyc_output/ | ||
.tests-output/ | ||
|
||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import test from "ava"; | ||
import { rollup } from "rollup"; | ||
import * as path from "path"; | ||
|
||
import sass from "../src/index"; | ||
import { | ||
TEST_UTILS, | ||
TEST_BASE_CONFIG, | ||
TEST_SASS_OPTIONS_DEFAULT, | ||
TEST_GENERATE_OPTIONS, | ||
TEST_OUTPUT_DIR, | ||
} from "./utils"; | ||
|
||
test("should import *.scss and *.sass files", async (t) => { | ||
const outputBundle = await rollup({ | ||
input: "test/fixtures/basic/index.js", | ||
...TEST_BASE_CONFIG, | ||
}); | ||
const { output } = await outputBundle.generate({ | ||
format: "es", | ||
file: path.join(TEST_OUTPUT_DIR, "import_scss_and_sass.js"), | ||
}); | ||
const result = TEST_UTILS.getOutputFirstChunkCode(output); | ||
|
||
t.snapshot(result); | ||
}); | ||
|
||
test("should import *.scss and *.sass files with default configuration", async (t) => { | ||
const outputBundle = await rollup({ | ||
input: "test/fixtures/basic/index.js", | ||
plugins: [sass()], | ||
}); | ||
const { output } = await outputBundle.generate({ | ||
...TEST_GENERATE_OPTIONS, | ||
file: path.join(TEST_OUTPUT_DIR, "import_scss_and_sass_default_options.js"), | ||
}); | ||
const result = TEST_UTILS.getOutputFirstChunkCode(output); | ||
|
||
t.snapshot(result); | ||
}); | ||
|
||
test("should compress the dest CSS", async (t) => { | ||
const outputBundle = await rollup({ | ||
...TEST_BASE_CONFIG, | ||
input: "test/fixtures/compress/index.js", | ||
}); | ||
const { output } = await outputBundle.generate(TEST_GENERATE_OPTIONS); | ||
const result = TEST_UTILS.getOutputFirstChunkCode(output); | ||
|
||
t.snapshot(result); | ||
}); | ||
|
||
test("should support options.data", async (t) => { | ||
const jsVars = { | ||
color_red: "red", | ||
}; | ||
const scssVars = Object.entries(jsVars).reduce( | ||
(prev, [varName, varValue]) => `${prev}$${varName}:${varValue};`, | ||
"" | ||
); | ||
const outputBundle = await rollup({ | ||
input: "test/fixtures/data/index.js", | ||
plugins: [ | ||
sass({ | ||
options: { | ||
...TEST_SASS_OPTIONS_DEFAULT, | ||
data: scssVars, | ||
}, | ||
}), | ||
], | ||
}); | ||
const { output } = await outputBundle.generate(TEST_GENERATE_OPTIONS); | ||
const result = TEST_UTILS.getOutputFirstChunkCode(output); | ||
|
||
t.snapshot(result); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
So for TEST_UTILS, could you change the exports to just the methods themselves - Since they already live at 'test/utils' it becomes redundant to export the object
TEST_UTILS
- What would be good here would be to renamesquash
tostripNewLines
, or something similar!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.
Also,
getOutputFirstChunkCode
could just begetFirstChunkCode
- since the declaration would readgetFirstChunkCode(output: ...) ...
- Would also changeoutput
tochunks
, and/or,outputChunks
for more correlation between whatoutput
constants actually represent.