npm install cypress --save-dev
npx cypress open
→自動でcypress.jsonとcypress用のディレクトリが作られるcypress.json
に設定を追加する
{
"baseUrl": "http://localhost:8080",
"viewportWidth": 1280,
"video": true,
const double = x => x * 2; | |
const over5 = x => x > 5; | |
const a = [1, 2, 3].map(double).filter(over5); | |
console.log('********* a', a); | |
import * as R from 'ramda'; | |
const times2Over5 = R.compose( | |
R.tap(console.log), |
{ | |
"data": [ | |
{ | |
"id": 1, | |
"title": "Reactコンポーネントを作れるようになる", | |
"done": false, | |
"created_at": "2018-08-08 12:00:00", | |
"started_at": "", | |
"done_at":"" | |
}, |
const insertItem = (xs, index, item) => [...xs.slice(0, index), item, ...xs.slice(index)]; | |
const range = number => [...Array(number).keys()]; | |
const permutate = (xs, accum = []) => { | |
const [head, ...tail] = xs; | |
if (!head) { | |
return accum; | |
} | |
return accum.length === 0 |
const pad = (leftOrRight = 'left') => maxLength => char => value => { | |
const strValue = typeof value === 'number' ? value.toString() : value; | |
if (strValue.length >= maxLength) { | |
return strValue; | |
} | |
if (typeof maxLength !== 'number') { | |
throw new Error('maxLength should be a number'); | |
} | |
const padding = Array(maxLength - strValue.length) |
func splitByRegexp(str string, separator string) []string { | |
normalRe := "[^%s]*[%s]" | |
rawRe := `[^%s]*[%s]` | |
var re *regexp.Regexp | |
if strings.Index(separator, `\\`) > -1 { | |
re = regexp.MustCompile(fmt.Sprintf(normalRe, separator, separator)) | |
} else { | |
re = regexp.MustCompile(fmt.Sprintf(rawRe, separator, separator)) | |
} |
async (callback) => { | |
const { err, ...result } = await asyncCode().catch(e => ({ err: e })); | |
if (err) { | |
callback(err); | |
return; | |
} | |
callback(null, result); | |
}; |
async (callback) => { | |
try { | |
const result = await asyncCode(); | |
callback(null, result) | |
} | |
catch (e) { | |
callback(e) | |
} | |
} |
async (callback) => { | |
const result = await asyncCode(); | |
callback(null, result) | |
} |
//ミドルウェアでやる場合 | |
app.configure(function(){ | |
//・・・(略)・・・ | |
app.use(function (req, res, next) { | |
app.locals.message = req.session.message; | |
next(); | |
}); | |
//・・・(略)・・・ | |
}); |