我正在使用lint-staged和Jest测试框架来测试上次提交中已更改的文件,如本博客所述.
我的配置如下:
"src/**/*.{ts}": [
"prettier --write",
"tslint --fix --project .",
"jest --bail --findRelatedTests",
"git add"
]
Run Code Online (Sandbox Code Playgroud)
我还想为仅更改的文件生成coverage报告.为此,我必须将更改的文件列表放在多个位置.
jest --bail --findRelatedTests <spaceSeparatedListOfSourceFiles> --collectCoverageFrom=<glob>
使用lint-staged,如何仅针对已更改的文件限制测试和覆盖率报告?
我正在使用带有TypeScript的joi和@ types/joi.Joi有一个extend方法,它允许通过返回一个新实例来扩展joi,而无需修改原始的joi库.我用它创建了一个扩展实例.
为了这个扩展实例创建的定义,我试图Module Augmentation
描述这里使用下面的代码:
declare module 'joi' {
// Add a new Schema type which has noChildren() method.
interface CustomSchema extends ObjectSchema {
noChildren(): this;
}
}
Run Code Online (Sandbox Code Playgroud)
但是,正如预期的那样,这会通过扩充来修改原始定义.我想要的是为扩展实例创建定义,它继承原始内容而不修改它.
还扩展Joi
了如下:
import * as Joi from 'joi';
const JoiExtended = Joi.extend({...some implementation...})
// How to export?
// export * from 'Joi' ---> In this case, original non-extended Joi is exported
// export default JoiExtended ---> Imported `Joi` reports: Cannot find …
Run Code Online (Sandbox Code Playgroud) 传奇:
如何模拟类似钻石(如果术语正确)的关系?最好用一个简化的例子来解释:
有organization
,item
和tag
实体。
我的目标是建模:
tag
都是独一无二的,属于一个组织。item
都是独一无二的,属于一个组织。tag
/item
对必须属于同一组织。(即来自组织 A 的项目不能与来自组织 B 的标签配对)我绘制了两种替代解决方案,但没有一个让我满意。
图1个断裂第三目标:items
和tags
使用是自己唯一id
的主键,但没有什么可以阻止插入到对item_tag
属于不同的组织。
图2不破,但弯曲第一和第二目标:organization_id
加入作为主键和外键item
和tag
表和item_tag.organization_id
列引用两者。这可以防止来自不同组织的配对。tag.id
anditem.id
列现在是不必要的复合主键的一部分,因为实际上单列id
表示item
and 的唯一性tag
。
我如何正确地为这些需求建模?
typescript ×2
erd ×1
javascript ×1
jestjs ×1
joi ×1
json ×1
lint-staged ×1
mysql ×1
node.js ×1
postgresql ×1