【发布时间】:2021-01-27 22:27:44
【问题描述】:
我需要为我的 wdio 打字稿框架制作一个自定义匹配器。我查看了https://github.com/webdriverio/expect-webdriverio/blob/master/docs/Extend.md 并完成了所有操作,我复制并粘贴了完全相同的代码。所以在我的 before() 钩子中:
const matchers = require('myMatchers');
matchers.addCustomMatchers();
就在我的 wdio conf 文件旁边:
module.exports = {
addCustomMatchers: () => {
console.log("MY MATCHER");
expect.extend({
myMatcher(actual, expected) {
return { pass: actual === expected, message: () => 'some message' }
},
})
}
}
当我开始测试时,我在控制台中看到“MY MATCHER”行。所以它得到正确执行。 但是我在尝试做期望时看不到 myMatcher。我错过了什么?
【问题讨论】:
-
“看不到 myMatcher”。不知道是什么意思。你在哪里看不到?