首页 > 解决方案 > 如何使用 Spectron 执行 getPath?

问题描述

在我的 Electron 应用程序中,我remote.app.getPath('documents'用来获取用户当前文档目录的路径。我也使用 Spectron 并且想在我的测试中访问这个目录。

在我的 Spectron 测试中执行此功能的最佳方法是什么?

不幸remote.app的是未定义,因此不可用,而且Application它本身也没有任何功能。

test.beforeEach(async (t) => {
  (t.context as any).app = new spectron.Application({
    path: electronPath,
    args: [appPath]
  });

  // how to call getPath here?

  return (t.context as any).app.start();
});

标签: node.jselectronspectron

解决方案


推荐阅读