我只是通过 npm 安装 web-component-tester 并尝试通过 wct 命令运行测试,但出现错误。
WCT 命令不起作用 cmd 无法识别此命令
<head>
<meta charset="UTF-8">
<title>Title</title>
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">
<script src="../node_modules/web-component-tester/browser.js"></script>
<script src="../button/solid-button.js"></script>
</head>
<body>
<solid-button></solid-button>
<script>
suite('<solid-button>', function () {
let component = document.querySelector('solid-button');
test('renders button', () => {
assert.isOk(component.shadowRoot.querySelector('button'));
});
});
</script>
</body>
const button= document.createElement("button");
button.innerText="solid button";
class SolidButton extends HTMLElement {
constructor() {
super();
this.attachShadow({mode: 'open'});
this.shadowRoot.appendChild(button);
}
connectedCallback(){}
}
window.customElements.define('solid-button', SolidButton);
'wct' 不是内部或外部命令、可运行程序或批处理文件。