Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
bun-match-svg
Advanced tools
A custom matcher for Bun tests to compare SVG snapshots.
The fastest way to get started is to use the CLI to initialize your project:
bunx bun-match-svg init
This will:
tests/svg.test.ts
tests/fixtures/preload.ts
bunfig.toml
You can then run the example test:
bun test
bun add -D bun-match-svg
Import the library in your test file:
import "bun-match-svg"
test("your SVG test", () => {
const svgContent = generateSomeSvg() // Your function to generate SVG
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "uniqueName")
})
The toMatchSvgSnapshot
matcher takes two arguments:
import.meta.path
: The path of the current test file.uniqueName
(optional): A unique name for the snapshot. If not provided, it will use the test file name.To make toMatchSvgSnapshot
available in all your test files without importing it in each one:
tests/fixtures/preload.ts
with the following content:import "bun-match-svg"
bunfig.toml
file in your project root with:[test]
preload = ["./tests/fixtures/preload.ts"]
Now toMatchSvgSnapshot
will be automatically available in every test file.
To update existing snapshots, run your tests with:
bun test --update-snapshots
Or set the environment variable:
BUN_UPDATE_SNAPSHOTS=1 bun test
The matcher uses looks-same
for comparison with these default settings:
strict: false
tolerance: 2
There currently isn't a way to configure this, but PRs welcome!
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.
FAQs
A custom matcher for Bun tests to compare SVG snapshots.
The npm package bun-match-svg receives a total of 700 weekly downloads. As such, bun-match-svg popularity was classified as not popular.
We found that bun-match-svg demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.