代码格式在 Visual Studio Code 中似乎不起作用。我已经尝试过shift+alt+f,但它不会格式化 html 代码。我运行ctrl+shift+p并输入 Format ,我唯一的选项是 Format Document( shift+alt+f) 和 Format Selection(没有格式代码)。我不明白我做错了什么?我是否需要安装某种扩展才能使这种格式适用于 html 文件?
我正在使用 webdriverIO v7(最新稳定版本)和黄瓜。
我收到该错误:Error: The "from" argument must be of type string. Received undefined
这是堆栈跟踪:
2021-04-08T18:29:37.403Z ERROR @wdio/runner: TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received undefined
at validateString (internal/validators.js:120:11)
at Object.relative (path.js:437:5)
at getDefinitionLineAndUri (C:\my-project\node_modules\cucumber\lib\support_code_library_builder\build_helpers.js:184:27)
at buildStepDefinitionConfig (C:\my-project\node_modules\cucumber\lib\support_code_library_builder\build_helpers.js:124:7)
at SupportCodeLibraryBuilder.defineStep (C:\my-project\node_modules\cucumber\lib\support_code_library_builder\index.js:51:79)
at Object.<anonymous> (C:\my-project\src\step_definitions\/accountSummary_steps.js:6:1)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Module._compile (C:\my-project\node_modules\pirates\lib\index.js:99:24)
at Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Object.newLoader [as .js] (C:\my-project\node_modules\pirates\lib\index.js:104:7)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Module._load (internal/modules/cjs/loader.js:878:14)
at Function.hookedLoader [as _load] (C:\my-project\node_modules\mockery\mockery.js:111:12)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18) …Run Code Online (Sandbox Code Playgroud) 我有这样的代码:
get alcoholLink() {
return $('a=Alcohol');
}
Run Code Online (Sandbox Code Playgroud)
这是有效的 webriverio 选择器,用于获取带有文本“Alcohol”的元素。
但 IntelliJ IDEA 将其标为红色下划线并显示“意外令牌”错误。
有谁知道如何调整 IntelliJ 设置以便将代码识别为有效的 webdriverio 选择器?
谢谢,米斯玛斯
我在 package.json 文件中有这个:
{
"name": "test demo",
"version": "1.0.0",
"description": "test demo scripts",
"scripts": {
"test:v1": "wdio src/resources/config/wdio.chrome.conf.js --spec test/Tests.spec.ts",
"test:v2": "wdio src/resources/config/wdio.firefox.conf.js --spec test/Tests.spec.ts",
"test": "npm run test:v1 && npm run test:v2"
},
...
}
Run Code Online (Sandbox Code Playgroud)
当运行此命令时:
npm run test
Run Code Online (Sandbox Code Playgroud)
如果test:v1失败,则test:v2根本不执行脚本。
有没有一种方法可以配置它,以便所有脚本都运行,无论其中一些脚本是否失败?
编辑:当我在 package.json 中尝试此操作时:
"test": "npm run test:v1 ; npm run test:v2"
Run Code Online (Sandbox Code Playgroud)
然后我仍然没有执行这两个脚本,只是test:v1执行时出错。
这是我在控制台中得到的:
C:\2020\demo>npm run test
> demo@1.0.0 test C:\2020\demo
> npm run test:v1 ; npm run test:v2
> demo@1.0.0 test:v1 C:\2020\demo …Run Code Online (Sandbox Code Playgroud) 我正在使用 VS Code 和 Cucumber 扩展https://marketplace.visualstudio.com/items?itemName=alexkrechik.cucumberautocomplete&ssr=false#overview不起作用。这是我的 .vscode 文件夹中的 settings.json:
{
"cucumberautocomplete.steps": [
"src/step_definitions/*.js",
],
"cucumberautocomplete.syncfeatures": "src/features/*feature",
"cucumberautocomplete.strictGherkinCompletion": true,
"cucumberautocomplete.strictGherkinValidation": true,
"cucumberautocomplete.smartSnippets": true,
"cucumberautocomplete.stepsInvariants": true,
// "cucumberautocomplete.pages": {
// "users": "test/features/page_objects/users.storage.js",
// "pathes": "test/features/page_objects/pathes.storage.js",
// "main": "test/features/support/page_objects/main.page.js"
// },
"cucumberautocomplete.skipDocStringsFormat": true,
"cucumberautocomplete.formatConfOverride": {
"And": 3,
"But": "relative",
},
"cucumberautocomplete.onTypeFormat": true,
"editor.quickSuggestions": {
"comments": false,
"strings": true,
"other": true
},
"cucumberautocomplete.gherkinDefinitionPart": "(Given|When|Then)\\(",
"cucumberautocomplete.stepRegExSymbol": "'"
}
Run Code Online (Sandbox Code Playgroud)
这是我添加到 VS Code 的 settings.json 中的内容:
{
"workbench.colorTheme": "Default Light+",
"editor.quickSuggestions": true,
"window.zoomLevel": 0
} …Run Code Online (Sandbox Code Playgroud) 我有包含这些记录的表 audit_log:
log_id | request_id | status_id
1 | 2 | 5
2 | 2 | 10
3 | 2 | 20
4 | 3 | 10
5 | 3 | 20
Run Code Online (Sandbox Code Playgroud)
我想知道是否存在同时具有 status_id 5 和 10 的 request_ids。所以这个查询应该返回 request_id = 2 因为它的列 status_id 有值 5 和 10(request_id 3 被省略,因为 status_id 列只有 10 没有 5 的值)。
我怎么能用 SQL 做到这一点?
我想我应该按 request_id 使用 group,但我不知道如何检查 group 是否具有值为 5 和 10 的 status_id?
谢谢,
米斯马
如何使用js文件作为fixture?有这方面的例子吗?我在 user-details.js 中尝试过:
data = {
email: function () {
const currentTimestamp = new Date().getTime();
return `test${currentTimestamp}@test.com`
},
firstName: 'Max',
lastName: 'Mustermann',
street: 'Some Street',
}
Run Code Online (Sandbox Code Playgroud)
然后在我的规范文件中我这样做:
beforeEach(function () {
cy.fixture(env + '/user-details').as('userDetails');
});
Run Code Online (Sandbox Code Playgroud)
在it同一规范文件的测试块中:
const userDetails = this.userDetails.data;
actions.insertStreet(userDetails.street);
Run Code Online (Sandbox Code Playgroud)
但它说它无法读取未定义的属性“street”。有什么想法如何正确地做到这一点吗?:汗水微笑:
我想找到一个合适的算法来解决这个问题:
假设我们有N个项目,我们知道每个项目将获得多少资金,以及每个项目需要多少时间(每个项目的预计时间).我们有一定的时间来完成所有项目.我们希望选择项目以使我们的利润最大化,并且总体估计时间不会超过可用时间.你能告诉我应该使用哪种优化算法吗?有没有我可以在C#,.NET技术或Java技术中使用的东西?
webdriver-io ×3
cucumber ×2
javascript ×2
.net ×1
algorithm ×1
c# ×1
cypress ×1
group-by ×1
java ×1
node.js ×1
npm-scripts ×1
optimization ×1
oracle ×1
package.json ×1
sql ×1