我正在使用 Quasar、Electron 和串行端口设置一个测试项目。使用最少的串行端口测试启动应用程序时,出现以下错误:
vue-router.esm.js?85f8:2128 TypeError: Cannot read property 'indexOf' of undefined
at Function.getFileName (bindings.js?d8c5:178)
at bindings (bindings.js?d8c5:82)
at eval (win32.js?0965:1)
at Object../node_modules/@serialport/bindings/lib/win32.js (vendor.js:340)
at __webpack_require__ (app.js:854)
at fn (app.js:151)
at eval (index.js?3983:6)
at Object../node_modules/@serialport/bindings/lib/index.js (vendor.js:252)
at __webpack_require__ (app.js:854)
at fn (app.js:151)
Run Code Online (Sandbox Code Playgroud)
当我只包含 serialport 包而不做更多时,甚至会发生错误。这似乎是一个基本问题。重现问题的代码:
<script lang="ts">
import { Vue, Component } from 'vue-property-decorator';
import SerialPort from 'serialport';
@Component
export default class Index extends Vue {
test() {
console.log('test', SerialPort);
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
我尝试了我能在这里找到的所有东西,在类星体论坛等。 pp.: electron-rebuild,试图将串行端口配置为外部依赖项,......
我不太确定重建过程是否按预期工作,但我不知道要检查什么以确保它确实如此。带有串行端口的电子示例项目对我有用。也许它与类星体有关?
我可以获得有关重建过程的更多信息吗?我尝试了指定版本的不同组合,但没有任何帮助。
我也在串行端口存储库中提出了这个问题,但是将它添加到 …
Is there a way to write more data driven tests with Jestjs?
I came up with something like this:
it('assignments and declarations', () => {
testCases.forEach(function (testCase) {
const slx = fs.readFileSync(testDirectory + 'slx/' + testCase.slx, 'utf-8');
const document = compiler.parse(slx);
const lmsGenerator = new LMSGenerator(document);
const lms = lmsGenerator.generate();
const expected = fs.readFileSync(testDirectory + 'lms/' + testCase.lms, 'utf-8');
expect(expected).toBe(lms);
});
});
Run Code Online (Sandbox Code Playgroud)
I read the input and the expected output out of files. The files (and the link between input …
我目前正在寻找在 Electron 项目中使用 USB 的解决方案。
我发现很多线程不仅仅是在堆栈溢出中。但所有人都在陈述不同的事情。有人说它运行良好(很容易),其他人说它甚至不可能。
我偶然发现了 usb-electron 但这仅适用于 Electron prebuild 1.0.2(据我所知)。
有人在一个项目中成功使用 Electron 和 USB 吗?您将这种组合用于哪些设备?也许有人正在使用另一种解决方案?就像背景中的 C#(或其他)二进制文件一样,在电子内触发并执行所有 USB 操作?
我感谢每一个提示!
更新:
我尝试了那些提到的解决方案并遇到了各种错误。我也从未设法针对电子构建 USB 或串行端口包。如果我使用 serialport 包,则电子 1.4.12 会出现以下错误:
angular.js:14328 Error: Eine DLL-Initialisierungsroutine ist fehlgeschlagen.
\\?\E:\Masterthesis\Simplex-Electron\node_modules\serialport\build\Release\serialport.node
at Error (native)
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
at Object.Module._extensions..node (module.js:583:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at bindings (E:\Masterthesis\Simplex-Electron\node_modules\bindings\bindings.js:76:44)
Run Code Online (Sandbox Code Playgroud)
第一行只是说一个 DLL 例程失败了。