问题描述
我在我正在运行的测试中修改了这个例子
https://embed.plnkr.co/plunk/OJpuhX
这是我在那个例子中的代码块:
index.html
<!DOCTYPE html>
<html>
<head>
<link data-require="qunit@*" data-semver="1.17.1" rel="stylesheet"
href="http://code.jquery.com/qunit/qunit-1.17.1.css" />
<script data-require="qunit@*" data-semver="1.17.1" src="http://code.jquery.com/qunit/qunit-1.17.1.js"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script>
<script src="hello.js"></script>
<script src="hello.test.js"></script>
</body>
</html>
add.js
export class showAlert {
static msg() {
alert('Hello World!');
// retmsg = 'Hello World!'
// return retmsg;
}
}
hello.test.js
import ('hello.ts');
QUnit.test("hello test",function (assert) {
assert.ok(hello.hello() === 'Hello World!','Passed!');
});
hello.ts(以前称为 hello.js),如果由于 IMPORT 无法在模块之外工作,我无法导入它
var hello: any;
import { showAlert as _alert } from './add';
hello = function hello() {
alert('MakeTest: ' + _alert);
return 'Hello World!';
};
alert('Hello var: ' + hello);
我经常得到的错误是:
PS C:\Users\pborregg\repos\wwwroot\acquisition-global-components\src> npm test
> acquisition-aem-global-components@1.0.0 test C:\Users\pborregg\repos\wwwroot\acquisition-global-components\src
> karma start
START:
19 05 2021 13:31:35.547:WARN [filelist]: Pattern "C:/Users/pborregg/repos/wwwroot/acquisition-global-components/src/hello.js" does not match any file.
19 05 2021 13:31:35.600:INFO [karma-server]: Karma v6.3.2 server started at http://localhost:9876/
19 05 2021 13:31:35.643:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
19 05 2021 13:31:35.704:INFO [launcher]: Starting browser Chrome
19 05 2021 13:31:40.045:INFO [Chrome 90.0.4430.212 (Windows 10)]: Connected on socket lmNGV4w5POgtxbWPAAAB with id 46008113
× hello test
Finished in 0.018 secs / 0.003 secs @ 13:31:40 GMT-0700 (Pacific Daylight Time)
SUMMARY:
√ 0 tests completed
× 1 test Failed
Failed TESTS:
× hello test
Chrome 90.0.4430.212 (Windows 10)
Died on test #1 at hello.test.js:12:7: hello is not defined
ReferenceError: hello is not defined
at Object.<anonymous> (hello.test.js:13:15)
at runTest (C:/Users/pborregg/node_modules/qunit/qunit/qunit.js:2251:37)
at Test.run (C:/Users/pborregg/node_modules/qunit/qunit/qunit.js:2239:9)
at C:/Users/pborregg/node_modules/qunit/qunit/qunit.js:2461:16
at processtaskQueue (C:/Users/pborregg/node_modules/qunit/qunit/qunit.js:1849:33)
at C:/Users/pborregg/node_modules/qunit/qunit/qunit.js:1853:13
npm ERR! Test Failed. See above for more details.
注意:
感谢您的帮助。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)