漂亮会自动更改
given(myObject.myCall()).willAnswer {
throw IOException("Ooops")
}
对此
it(
"Throws error if item has source: false and doesn't have children",
() => {
const rawData = [{ slug: 'item-name', source: false }]
jest.doMock('../sidebar.json', () => rawData)
expect(() => require('./helper')).toThrow(
new Error(
"If you set 'source' to false, you had to add at least one child"
)
)
}
)
我的漂亮配置:
it("Throws error if item has source: false and doesn't have children", () => {
const rawData = [{ slug: 'item-name', source: false }]
jest.doMock('../sidebar.json', () => rawData)
expect(() => require('./helper')).toThrow(
new Error(
"If you set 'source' to false, you had to add at least one child"
)
)
})
它某种程度上不遵守semi: false
singleQuote: true
trailingComma: none
printWidth: 80
tabWidth: 2
useTabs: false
proseWrap: always
规则,而是将所有参数写入一行。
我当前的解决方法是printWidth
,但是有更好的解决方案吗?
答案 0 :(得分:0)
看起来更漂亮的测试框架函数调用与其他函数调用不同,将它们全部强制到同一行(我认为它看起来更漂亮)。