如何使 cypress 与 aurelia 一起使用 github 动作并在本地工作?
How can cypress be made to work with aurelia with github actions and locally?
好的,所以我在配置过程中将 cypress 添加到 aurelia,它运行良好。当我在 github 上将 cypress 设置为一个命令时,我无法让它将 puppeteer 识别为浏览器。因此,我转而使用官方的 github 柏树操作,并且有效
- name: test
uses: cypress-io/github-action@v1
with:
start: yarn start
browser: ${{matrix.browser}}
record: true
env:
# pass the Dashboard record key as an environment variable
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
但是我必须按如下方式设置 cypress.json
{
"baseUrl": "http://localhost:8080",
"fixturesFolder": "test/e2e/fixtures",
"integrationFolder": "test/e2e/integration",
"pluginsFile": "test/e2e/plugins/index.js",
"screenshotsFolder": "test/e2e/screenshots",
"supportFile": "test/e2e/support/index.js",
"videosFolder": "test/e2e/videos",
"projectId": "..."
}
现在 运行 yarn e2e
不起作用,因为没有服务器站起来,因为它不再通过 cypress.config.js
自己做
const CLIOptions = require( 'aurelia-cli').CLIOptions;
const aureliaConfig = require('./aurelia_project/aurelia.json');
const PORT = CLIOptions.getFlagValue('port') || aureliaConfig.platform.port;
const HOST = CLIOptions.getFlagValue('host') || aureliaConfig.platform.host;
module.exports = {
config: {
baseUrl: `http://${HOST}:${PORT}`,
fixturesFolder: 'test/e2e/fixtures',
integrationFolder: 'test/e2e/integration',
pluginsFile: 'test/e2e/plugins/index.js',
screenshotsFolder: 'test/e2e/screenshots',
supportFile: 'test/e2e/support/index.js',
videosFolder: 'test/e2e/videos'
}
};
我怎样才能使 yarn e2e
像以前一样工作,并让它在 github 上工作?(我不在乎等式的哪一边改变了)
这里 yarn e2e
不确定 au 在幕后做了什么。
"e2e": "au cypress",
最简单的方法是创建一个 test/e2e/cypress-config.json
{
"baseUrl": "http://localhost:8080",
"fixturesFolder": "test/e2e/fixtures",
"integrationFolder": "test/e2e/integration",
"pluginsFile": "test/e2e/plugins/index.js",
"screenshotsFolder": "test/e2e/screenshots",
"supportFile": "test/e2e/support/index.js",
"videosFolder": "test/e2e/videos",
"projectId": "1234"
}
,然后像这样设置 github 操作。
- name: test
uses: cypress-io/github-action@v1
with:
config-file: tests/e2e/cypress-config.json
start: yarn start
browser: ${{matrix.browser}}
record: true
env:
# pass the Dashboard record key as an environment variable
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
路径无所谓,只要配置相同即可。只要确保它不与 aurelia 想要的重叠即可。
好的,所以我在配置过程中将 cypress 添加到 aurelia,它运行良好。当我在 github 上将 cypress 设置为一个命令时,我无法让它将 puppeteer 识别为浏览器。因此,我转而使用官方的 github 柏树操作,并且有效
- name: test
uses: cypress-io/github-action@v1
with:
start: yarn start
browser: ${{matrix.browser}}
record: true
env:
# pass the Dashboard record key as an environment variable
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
但是我必须按如下方式设置 cypress.json
{
"baseUrl": "http://localhost:8080",
"fixturesFolder": "test/e2e/fixtures",
"integrationFolder": "test/e2e/integration",
"pluginsFile": "test/e2e/plugins/index.js",
"screenshotsFolder": "test/e2e/screenshots",
"supportFile": "test/e2e/support/index.js",
"videosFolder": "test/e2e/videos",
"projectId": "..."
}
现在 运行 yarn e2e
不起作用,因为没有服务器站起来,因为它不再通过 cypress.config.js
const CLIOptions = require( 'aurelia-cli').CLIOptions;
const aureliaConfig = require('./aurelia_project/aurelia.json');
const PORT = CLIOptions.getFlagValue('port') || aureliaConfig.platform.port;
const HOST = CLIOptions.getFlagValue('host') || aureliaConfig.platform.host;
module.exports = {
config: {
baseUrl: `http://${HOST}:${PORT}`,
fixturesFolder: 'test/e2e/fixtures',
integrationFolder: 'test/e2e/integration',
pluginsFile: 'test/e2e/plugins/index.js',
screenshotsFolder: 'test/e2e/screenshots',
supportFile: 'test/e2e/support/index.js',
videosFolder: 'test/e2e/videos'
}
};
我怎样才能使 yarn e2e
像以前一样工作,并让它在 github 上工作?(我不在乎等式的哪一边改变了)
这里 yarn e2e
不确定 au 在幕后做了什么。
"e2e": "au cypress",
最简单的方法是创建一个 test/e2e/cypress-config.json
{
"baseUrl": "http://localhost:8080",
"fixturesFolder": "test/e2e/fixtures",
"integrationFolder": "test/e2e/integration",
"pluginsFile": "test/e2e/plugins/index.js",
"screenshotsFolder": "test/e2e/screenshots",
"supportFile": "test/e2e/support/index.js",
"videosFolder": "test/e2e/videos",
"projectId": "1234"
}
,然后像这样设置 github 操作。
- name: test
uses: cypress-io/github-action@v1
with:
config-file: tests/e2e/cypress-config.json
start: yarn start
browser: ${{matrix.browser}}
record: true
env:
# pass the Dashboard record key as an environment variable
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
路径无所谓,只要配置相同即可。只要确保它不与 aurelia 想要的重叠即可。