Skip to content

Instantly share code, notes, and snippets.

@theKashey
Created March 19, 2019 04:24
Show Gist options
  • Save theKashey/151fc58a06e191b1142964981ffbf029 to your computer and use it in GitHub Desktop.
Save theKashey/151fc58a06e191b1142964981ffbf029 to your computer and use it in GitHub Desktop.
ava rewiremock
import test from 'ava';
import sinon from 'sinon';
// nothing would be mocked before import
import rewiremock from 'rewiremock/node';
import fs from 'fs';
// ^ only this "FS" would be mocked
rewiremock('fs').mockThrough(() => sinon.stub());
// ^ this line would be "hoisted"
// here rewiremock would disable itself.
fs.mount('/some/test/directory/', "what you were going to do?");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment