测试

    这个仓库为 JavaScript 和 C ++ 提供了linting 规则 - 以及单元和集成测试。 通过 coding-style文档来学习更多的Electron’s编码风格

    为确保您的JavaScript符合Electron编码风格,请执行,它将针对Electron本身以及单元测试运行standard测试。 如果您正在使用带有插件/插件系统的编辑器,那么可以使用之类的插件在你提交代码前来检查编码规范。

    若要用参数运行standard测试,首先执行npm run lint-js -- 然后输入要传递给standard测试的参数。

    There is not a lot of Python in this repository, but it too is governed by coding style rules. will check all Python, using pylint to do so.

    单元测试

    If you are not using , ensure that that name you have configured for your local build of Electron is one of Testing, Release, Default, Debug, or you have set process.env.ELECTRON_OUT_DIR. Without these set, Electron will fail to perform some pre-testing steps.

    要运行所有单元测试,请执行 npm run test。 单元测试其实也是一个Electron应用!你可以在 文件夹中找到它。 请注意,单元测试也有自己的 package.json,因此它的依赖没有在最顶层的package.json中定义。

    Extra steps to run the unit test:

    1. Visual Studio 2019 must be installed.
    2. Node headers have to be compiled for your configuration.
    3. The electron.lib has to be copied as node.lib.
      1. cd out\Testing
      2. mkdir gen\node_headers\Release

    Missing fonts

    一些 Windows 10 设备上没有默认安装Meriryo字体,这会导致字体回退测试的失败。 要安装Meiryo字体:

    1. 按下Windows key并搜索 管理可选功能
    2. 单击添加功能
    3. 选择Japanese Supplemental Fonts并单击 安装

    Pixel measurements

    由于浮点数精度误差,某些依赖于精确像素测量的测试可能无法正常在Hi-DPI屏幕的设备上工作。 为了使这些测试能正常运行,请确保设备的缩放比为100%。

    要配置缩放比:

    1. 按下Windows key并搜索显示设置.
    2. Scale and layout下,确保缩放比为100%。