This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"films": [ | |
{ | |
"id": 1, | |
"title": "Star Trek: The motion picture", | |
"year": "1979", | |
"director_id": 1 | |
}, | |
{ | |
"id": 2, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SERVER_ENV from './server.config'; | |
var environment = process.env.NODE_ENV || 'development'; | |
var serverConf = SERVER_ENV[environment]; | |
export { | |
serverConf | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SERVER_ENV = { | |
'production': { port: process.env.SERVER_PORT }, | |
'development': { port: 4850 } | |
}; | |
export default SERVER_ENV; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { serverConf } from './config'; | |
import express from 'express'; | |
import bodyParser from 'body-parser'; | |
var app = express(); | |
app.use(bodyParser.json()); | |
app.use(bodyParser.urlencoded({ extended: true })); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import log4js from 'log4js'; | |
var logger = log4js.getLogger('server.js'); | |
logger.level = 'all'; | |
import { serverConf } from './config'; | |
import express from 'express'; | |
import bodyParser from 'body-parser'; | |
var app = express(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sum = (a, b) => { | |
return a + b; | |
}; | |
const dif = (a, b) => { | |
return a - b; | |
}; | |
export { | |
sum, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "jest.testing.manual.mocking", | |
"version": "1.0.0", | |
"description": "Basic script in order to test the Jest Testing Framework manual mocking.", | |
"main": "src/app.js", | |
"scripts": { | |
"dev": "NODE_ENV=development nodemon --watch src --exec babel-node src/app.js", | |
"test": "jest --watch" | |
}, | |
"repository": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as calculator from './utils/calculator'; | |
const doASum = () => { | |
let a = 5; | |
let b = 10; | |
return calculator.sum(a, b); | |
}; | |
const doADif = () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'jest'; | |
import * as app from '../src/app'; | |
describe('Testing the use of the \'calculator\' module', () => { | |
test('Testing doASum ...', () => { | |
expect(app.doASum()).toEqual(15); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'jest'; | |
var sum = jest.fn().mockReturnValue(20); | |
var dif = jest.fn().mockReturnValue(-20); | |
const calculator = jest.mock('../calculator', () => { | |
return { | |
sum, | |
dif | |
}; |
OlderNewer