有没有办法 运行 测试有 test.meta 的 TestCafe 利用 运行ner?
Is there way to run test which have test.meta of TestCafe utilizing runner?
我有一个只想执行的测试,test.meta。请在下面找到我的代码。
这是一个测试规范
.spec.ts
import { takeSnapshot } from 'testcafe-blink-diff';
import { AdminHomePage, LoginPage } from '../../pages';
import { config } from '../../config/tescafe.config';
const loginPage: LoginPage = new LoginPage();
const adminHomePage: AdminHomePage = new AdminHomePage();
fixture(`Practice utilization chart`)
.page(config.baseUrl)
.beforeEach(async () => {
await loginPage.login(config.envCredentials.admin.email, config.envCredentials.admin.password);
});
test.meta({ type: 'visual' })('Can view utilization chart with default interval ', async (t) => {
await t.expect(adminHomePage.practicesUtilizationChart.chart.exists).ok();
await t.expect(adminHomePage.practicesUtilizationChart.weekOption.innerText).eql('Week');
await takeSnapshot(t, {
fullPage: false,
timeout: 2000,
selector: adminHomePage.practicesUtilizationChart.chart,
});
});
这是一个 runner.js 做同样的事情
// eslint-disable-next-line @typescript-eslint/no-var-requires
const createTestCafe = require('testcafe');
(async () => {
const testcafe = await createTestCafe('localhost', 1340);
try {
const runner = testcafe.createRunner();
await runner
.src(['./testcafe/specs/*/*.spec.ts'])
.browsers(['chrome:headless'])
.reporter([
'spec',
{
name: 'html',
output: './testcafe/artifacts/reports/report.html',
},
])
.screenshots('./testcafe/artifacts/screenshots', true)
.run({
selectorTimeout: 2000,
assertionTimeout: 2000,
pageLoadTimeout: 5000,
speed: 0.5,
});
// eslint-disable-next-line no-useless-catch
} catch (error) {
throw error;
} finally {
await testcafe.close();
}
})();
是否有可能 运行 测试使用这个 运行ner 和来自测试的元?
npx testcafe chrome:headless ./testcafe/specs/*/*.spec.ts --test-meta type=visual
运行测试
npm run test --test-meta type=visual
- 不 运行 测试,运行s 运行ner 具有相同的参数
package.json
"scripts": {
"test": "node testcafe/runner.js",
}
I know that there is an option to read parameters from cli or if I remove the runner or run using npx it works.
您可以使用以下选项按元数据过滤测试:
- --test-meta and --fixture-meta 命令行选项
- runner.filter 方法中的 testMeta 和 fixtureMeta 参数
- filter.testMeta and filter.fixtureMeta 配置文件属性
它们在 TestCafe documentation 中有描述。
我有一个只想执行的测试,test.meta。请在下面找到我的代码。
这是一个测试规范 .spec.ts
import { takeSnapshot } from 'testcafe-blink-diff';
import { AdminHomePage, LoginPage } from '../../pages';
import { config } from '../../config/tescafe.config';
const loginPage: LoginPage = new LoginPage();
const adminHomePage: AdminHomePage = new AdminHomePage();
fixture(`Practice utilization chart`)
.page(config.baseUrl)
.beforeEach(async () => {
await loginPage.login(config.envCredentials.admin.email, config.envCredentials.admin.password);
});
test.meta({ type: 'visual' })('Can view utilization chart with default interval ', async (t) => {
await t.expect(adminHomePage.practicesUtilizationChart.chart.exists).ok();
await t.expect(adminHomePage.practicesUtilizationChart.weekOption.innerText).eql('Week');
await takeSnapshot(t, {
fullPage: false,
timeout: 2000,
selector: adminHomePage.practicesUtilizationChart.chart,
});
});
这是一个 runner.js 做同样的事情
// eslint-disable-next-line @typescript-eslint/no-var-requires
const createTestCafe = require('testcafe');
(async () => {
const testcafe = await createTestCafe('localhost', 1340);
try {
const runner = testcafe.createRunner();
await runner
.src(['./testcafe/specs/*/*.spec.ts'])
.browsers(['chrome:headless'])
.reporter([
'spec',
{
name: 'html',
output: './testcafe/artifacts/reports/report.html',
},
])
.screenshots('./testcafe/artifacts/screenshots', true)
.run({
selectorTimeout: 2000,
assertionTimeout: 2000,
pageLoadTimeout: 5000,
speed: 0.5,
});
// eslint-disable-next-line no-useless-catch
} catch (error) {
throw error;
} finally {
await testcafe.close();
}
})();
是否有可能 运行 测试使用这个 运行ner 和来自测试的元?
npx testcafe chrome:headless ./testcafe/specs/*/*.spec.ts --test-meta type=visual
运行测试
npm run test --test-meta type=visual
- 不 运行 测试,运行s 运行ner 具有相同的参数
package.json
"scripts": {
"test": "node testcafe/runner.js",
}
I know that there is an option to read parameters from cli or if I remove the runner or run using npx it works.
您可以使用以下选项按元数据过滤测试:
- --test-meta and --fixture-meta 命令行选项
- runner.filter 方法中的 testMeta 和 fixtureMeta 参数
- filter.testMeta and filter.fixtureMeta 配置文件属性
它们在 TestCafe documentation 中有描述。