├── .gitignore ├── packages ├── grocery │ ├── __mocks__ │ │ ├── apple.js │ │ ├── banana.js │ │ └── sillyname.js │ ├── index.js │ ├── package-lock.json │ ├── index.test.js │ └── package.json ├── apple │ ├── __mocks__ │ │ └── sillyname.js │ ├── index.js │ ├── index.test.js │ └── package.json └── banana │ ├── __mocks__ │ └── sillyname.js │ ├── index.js │ ├── index.test.js │ └── package.json ├── lerna.json ├── jest.config.js ├── package.json └── integration.test.js /.gitignore: -------------------------------------------------------------------------------- 1 | **/node_modules 2 | **/coverage 3 | -------------------------------------------------------------------------------- /packages/grocery/__mocks__/apple.js: -------------------------------------------------------------------------------- 1 | module.exports = 'TEST'; 2 | -------------------------------------------------------------------------------- /packages/grocery/__mocks__/banana.js: -------------------------------------------------------------------------------- 1 | module.exports = 'TEST'; 2 | -------------------------------------------------------------------------------- /packages/apple/__mocks__/sillyname.js: -------------------------------------------------------------------------------- 1 | module.exports = () => 'TEST'; 2 | -------------------------------------------------------------------------------- /packages/banana/__mocks__/sillyname.js: -------------------------------------------------------------------------------- 1 | module.exports = () => 'TEST' ; 2 | -------------------------------------------------------------------------------- /packages/grocery/__mocks__/sillyname.js: -------------------------------------------------------------------------------- 1 | module.exports = () => 'TEST'; 2 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "lerna": "2.9.0", 3 | "packages": [ 4 | "packages/*" 5 | ], 6 | "version": "0.0.0" 7 | } 8 | -------------------------------------------------------------------------------- /packages/apple/index.js: -------------------------------------------------------------------------------- 1 | const sillyname = require('sillyname'); 2 | 3 | module.exports = `apple and ${sillyname()}`; 4 | -------------------------------------------------------------------------------- /packages/banana/index.js: -------------------------------------------------------------------------------- 1 | const sillyname = require('sillyname'); 2 | 3 | module.exports = `banana and ${sillyname()}`; 4 | -------------------------------------------------------------------------------- /packages/apple/index.test.js: -------------------------------------------------------------------------------- 1 | const apple = require('./'); 2 | 3 | test('returns correct string', () => { 4 | expect(apple).toBe('apple and TEST'); 5 | }); -------------------------------------------------------------------------------- /packages/banana/index.test.js: -------------------------------------------------------------------------------- 1 | const banana = require('./'); 2 | 3 | test('returns correct string', () => { 4 | expect(banana).toBe('banana and TEST'); 5 | }); -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | collectCoverage: true, 3 | collectCoverageFrom: [ 4 | 'packages/**/*.{js}', 5 | '!**/node_modules/**', 6 | ], 7 | }; 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "test": "jest" 4 | }, 5 | "devDependencies": { 6 | "jest": "^22.4.2", 7 | "lerna": "^2.9.0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/grocery/index.js: -------------------------------------------------------------------------------- 1 | const sillyname = require('sillyname'); 2 | const apple = require('apple'); 3 | const banana = require('banana'); 4 | 5 | console.log(`grocery and ${sillyname()}`); 6 | console.log(apple); 7 | console.log(banana); 8 | -------------------------------------------------------------------------------- /packages/grocery/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "requires": true, 3 | "lockfileVersion": 1, 4 | "dependencies": { 5 | "sillyname": { 6 | "version": "0.1.0", 7 | "resolved": "https://registry.npmjs.org/sillyname/-/sillyname-0.1.0.tgz", 8 | "integrity": "sha1-z9mIWOJJhnE0d3Xv47tRQfRsh9Y=" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/grocery/index.test.js: -------------------------------------------------------------------------------- 1 | const log = jest.fn(); 2 | console.log = log; 3 | const grocery = require('./'); 4 | test('outputs correct string', () => { 5 | expect(log.mock.calls.length).toBe(3); 6 | expect(log.mock.calls[0][0]).toBe('grocery and TEST'); 7 | expect(log.mock.calls[1][0]).toBe('TEST'); 8 | expect(log.mock.calls[2][0]).toBe('TEST'); 9 | }); -------------------------------------------------------------------------------- /packages/apple/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "apple", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "sillyname": "0.0.3" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/banana/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "banana", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "sillyname": "0.0.3" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/grocery/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "grocery", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "apple": "^1.0.0", 14 | "banana": "^1.0.0", 15 | "sillyname": "0.1.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /integration.test.js: -------------------------------------------------------------------------------- 1 | jest.unmock('apple'); 2 | jest.unmock('banana'); 3 | const log = jest.fn(); 4 | console.log = log; 5 | const grocery = require('./packages/grocery/'); 6 | test('outputs correct string', () => { 7 | expect(log.mock.calls.length).toBe(3); 8 | expect(log.mock.calls[0][0]).toBe('grocery and TEST'); 9 | expect(log.mock.calls[1][0]).toBe('apple and TEST'); 10 | expect(log.mock.calls[2][0]).toBe('banana and TEST'); 11 | }); 12 | --------------------------------------------------------------------------------