是否可以使用 TestCafe .meta 对象从 cli 中跳过测试 运行
Is it possible to use the TestCafe .meta object to skip tests running from the cli
我正在使用 TestCafe 运行 我的集成测试。我知道它有 test.skip
功能,当我在本地测试并想跳过一组我不 need/want 到 运行 的测试时,这非常有用......但我想知道是否有办法 运行 除了 --test-meta environmentSpecific=true
等之外的所有测试?
我们有许多不同的环境,我正在寻找一种通过 CLI 跳过测试的简单方法,具体取决于我们针对构建的环境。
是的,您可以使用 运行 TestCafe 的编程方式来完成。
看一个例子:
const createTestCafe = require('testcafe');
let testcafe = null;
createTestCafe('localhost', 1337, 1338)
.then(tc => {
testcafe = tc;
const runner = testcafe.createRunner();
return runner
.src('/tests')
.filter((testName, fixtureName, fixturePath, testMeta, fixtureMeta) => {
return !testMeta.environmentSpecific;
})
.browsers(['chrome', 'safari'])
.run();
})
.then(failedCount => {
console.log('Tests failed: ' + failedCount);
testcafe.close();
});
我无法发表评论,因为我没有 50 个代表...
@mlosev 你会如何过滤 .testcaferc.json 文件,就像你对 运行ner 所做的那样?
我想要 运行 所有测试,除了带有 toDo 元的测试:'yes'。当前配置文件:
{
"assertionTimeout": 5000,
"browsers": ["chrome --window-size=1920,1159"],
"concurrency": 7,
"pageLoadTimeout": 15000,
"reporter": {
"name": "spec",
"output": "artifacts/reports/test_suite_results"
},
"screenshots": {
"path": "artifacts/screenshots",
"pathPattern": "${TEST}_${DATE}_${TIME}.png",
"takeOnFails": true
},
"selectorTimeout": 5000,
"skipJsErrors": false,
"src": "tests",
"videoEncodingOptions": {
"aspect": "16:9",
"framerate": 30
},
"videoOptions": {
"failedOnly": true,
"pathPattern": "${TEST}_${DATE}_${TIME}.mp4",
"singleFile": false
},
"videoPath": "artifacts/recordings"
}
我正在使用 TestCafe 运行 我的集成测试。我知道它有 test.skip
功能,当我在本地测试并想跳过一组我不 need/want 到 运行 的测试时,这非常有用......但我想知道是否有办法 运行 除了 --test-meta environmentSpecific=true
等之外的所有测试?
我们有许多不同的环境,我正在寻找一种通过 CLI 跳过测试的简单方法,具体取决于我们针对构建的环境。
是的,您可以使用 运行 TestCafe 的编程方式来完成。 看一个例子:
const createTestCafe = require('testcafe');
let testcafe = null;
createTestCafe('localhost', 1337, 1338)
.then(tc => {
testcafe = tc;
const runner = testcafe.createRunner();
return runner
.src('/tests')
.filter((testName, fixtureName, fixturePath, testMeta, fixtureMeta) => {
return !testMeta.environmentSpecific;
})
.browsers(['chrome', 'safari'])
.run();
})
.then(failedCount => {
console.log('Tests failed: ' + failedCount);
testcafe.close();
});
我无法发表评论,因为我没有 50 个代表...
@mlosev 你会如何过滤 .testcaferc.json 文件,就像你对 运行ner 所做的那样?
我想要 运行 所有测试,除了带有 toDo 元的测试:'yes'。当前配置文件:
{
"assertionTimeout": 5000,
"browsers": ["chrome --window-size=1920,1159"],
"concurrency": 7,
"pageLoadTimeout": 15000,
"reporter": {
"name": "spec",
"output": "artifacts/reports/test_suite_results"
},
"screenshots": {
"path": "artifacts/screenshots",
"pathPattern": "${TEST}_${DATE}_${TIME}.png",
"takeOnFails": true
},
"selectorTimeout": 5000,
"skipJsErrors": false,
"src": "tests",
"videoEncodingOptions": {
"aspect": "16:9",
"framerate": 30
},
"videoOptions": {
"failedOnly": true,
"pathPattern": "${TEST}_${DATE}_${TIME}.mp4",
"singleFile": false
},
"videoPath": "artifacts/recordings"
}