Skip to content

Instantly share code, notes, and snippets.

@distributedlife
Last active June 1, 2016 01:15
Show Gist options
  • Save distributedlife/afd268b9e743b784526ac51f397145b3 to your computer and use it in GitHub Desktop.
Save distributedlife/afd268b9e743b784526ac51f397145b3 to your computer and use it in GitHub Desktop.
Imports are hoisted in es6
import sinon from 'sinon';
let config = require('./path/to/config');
sinon.stub(config, 'get').returns({ port: 1234 });
import * as database from './path/to/database'
//The port is whatever the default is from config.
//What is really going is the above is being intepreted as:
import sinon from 'sinon';
import * as database from './path/to/database'
let config = require('./path/to/config');
sinon.stub(config, 'get').returns({ port: 1234 });
import sinon from 'sinon';
let config = require('./path/to/config');
sinon.stub(config, 'get').returns({ port: 1234 });
let database = require('./path/to/database');
//The port is 1234
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment