我想编写一个测试来断言给定对象不具有某些属性。
说我有一个函数
function removeFooAndBar(input) {
delete input.foo;
delete input.bar;
return input;
}
Run Code Online (Sandbox Code Playgroud)
现在我想写一个测试:
describe('removeFooAndBar', () => {
it('removes properties `foo` and `bar`', () => {
const data = {
foo: 'Foo',
bar: 'Bar',
baz: 'Baz',
};
expect(removeFooAndBar(data))
.toEqual(expect.objectContaining({
baz: 'Baz', // what's left
foo: expect.not.exists() // pseudo
bar: undefined // this doesn't work, and not what I want
}));
});
});
Run Code Online (Sandbox Code Playgroud)
断言这一点的正确方法是什么?
每隔一段时间,我想#在 git 提交消息中包含以 开头的行。
问题是“有没有办法转义该#字符,使其不被解释为注释标记?”
请回答“是的,是..”或“否”。
这不是Start a git commit message with a hashmark (#)的重复。我只是想确认一下是否有可能逃脱。