Tiny JavaScript library to load fixtures of different formats.
Don't know why this isn't included in every testing framework already 🤷
const loadfxt = require('loadfxt').default;
console.log(loadfxt('test.txt').toBinaryString());
import loadfxt from 'loadfxt';
console.log(loadfxt('test.txt').toBinaryString());
- Binary data
loadfxt('<path/to/fixture>').toArrayBuffer();
- Binary string
Each byte is represented as one character in the resulting string.
loadfxt('<path/to/fixture>').toBinaryString();
- UTF-8 string
The loaded data will be represented in UTF-8 encoding.
loadfxt('<path/to/fixture>').toUtf8();
- JSON
loadfxt('<path/to/fixture>').toJson();