Storybookと同時にテストケースも確認できれば、小さいコンポーネントをTDD的に開発を行うことができるだろう、と思い、Specificationsというアドオンを使用してみました。
これを使うと、Storybook上でテストを実行でき、かつ、コンポーネントが機能を満たしているかをライブで確認しながら開発をすることができます。
# storybook起動
start-storybook
Storybookと同時にテストケースも確認できれば、小さいコンポーネントをTDD的に開発を行うことができるだろう、と思い、Specificationsというアドオンを使用してみました。
これを使うと、Storybook上でテストを実行でき、かつ、コンポーネントが機能を満たしているかをライブで確認しながら開発をすることができます。
# storybook起動
start-storybook
開発環境にDockerを使用しているが、Jestの起動がかなり遅かった。
ファイルのマウントと、複数CPUを使用する辺りで時間がかかっていたようなので、docker/for-mac#1358 を参考に高速化(起動まで60s以上だったのを5sほどに)した。
docker-compose.yml
volumes:
- .:/app
import assert from 'assert'; | |
/** | |
* VuexにおけるActionHandlerが、期待するMutationをcommitするかをテストする。 | |
* Vuexの型はこちらを参照 https://github.com/vuejs/vuex/blob/dev/types/index.d.ts | |
* @param {*} action テストしたいActionHandler | |
* @param {*} payload ActionHandlerに渡すpayload。'skip'を指定でテストを無視できる。 | |
* @param {object} state ActionHandlerに渡すActionContextのstate | |
* @param {array} expectedMutationsAndActions ActionHandlerがcommit/dispatchするオブジェクトの配列。 | |
* @param {object} additionalParams 任意。ActionHandlerに渡すActionContextの追加プロパティ。 |
{ | |
"scripts": { | |
"test": "jest --maxWorkers=1", | |
}, | |
"jest": { | |
"moduleFileExtensions": [ | |
"ts", | |
"js", | |
"vue" | |
], |
[ | |
{ "id": 1, | |
"name": "service1", | |
"hosts": [ | |
{ "id": 1, | |
"name": "olapi01", | |
"roleId" : 1, | |
"roleName": "API", | |
}, | |
{ "id": 2, |
[ | |
{ "id": 1, | |
"name": "service1", | |
"roles" : [ | |
{ "id" : 1, | |
"name": "API", | |
"hosts": [ | |
{ "id": 1, | |
"name": "olapi01", | |
}, |
var isArray = require("x-is-array") | |
var VPatch = require("../vnode/vpatch") | |
var isVNode = require("../vnode/is-vnode") | |
var isVText = require("../vnode/is-vtext") | |
var isWidget = require("../vnode/is-widget") | |
var isThunk = require("../vnode/is-thunk") | |
var handleThunk = require("../vnode/handle-thunk") | |
var diffProps = require("./diff-props") |
function groupHistory(histories) { | |
const structuredHistories = {}; | |
histories.forEach((h)=> { | |
if (structuredHistories[h.role_id]) { | |
structuredHistories[h.role_id].hosts.push(h); | |
} | |
structuredHistories[h.role_id] = {}; | |
structuredHistories[h.role_id].hosts = [h]; | |
}); |
{ | |
stack: [ | |
{functionName: 'fn', fileName: 'file.js', lineNumber: 32, columnNumber: 1}, | |
{functionName: 'fn2', fileName: 'file.js', lineNumber: 543, columnNumber: 32}, | |
{functionName: 'fn3', fileName: 'file.js', lineNumber: 8, columnNumber: 1} | |
] | |
} |