我使用的是Visual Studio Code 1.17版本,我的目标是调试当前的 typescript文件.我有一个构建任务正在运行,所以我总是有一个相应的javascript文件,如下所示:
src/folder1/folder2/main.ts
src/folder1/folder2/main.js
Run Code Online (Sandbox Code Playgroud)
我尝试过以下launch.json配置:
{
"type": "node",
"request": "launch",
"name": "Current File",
"program": "${file}",
"console": "integratedTerminal",
"outFiles": [
"${workspaceFolder}/${fileDirname}**/*.js"
]
}
Run Code Online (Sandbox Code Playgroud)
但我得到错误: Cannot launch program '--full-path-to-project--/src/folder1/folder2/main.ts' because corresponding JavaScript cannot be found.
但相应的JavaScript文件存在!
tsconfig.json:
{
"compileOnSave": true,
"compilerOptions": {
"target": "es6",
"lib": [
"es2017",
"dom"
],
"module": "commonjs",
"watch": true,
"moduleResolution": "node",
"sourceMap": true
// "types": []
},
"include": [
"src",
"test"
],
"exclude": [
"node_modules",
"typings"
]}
Run Code Online (Sandbox Code Playgroud) 我的团队最近讨论过这个问题,似乎无法确定实际/预期的行为:
如果您有以下安全规则:
match /categories/{document=**} {
allow update: if request.auth.uid != null
&& request.resource.data.firstName is string
&& request.resource.data.lastName is string;
}
Run Code Online (Sandbox Code Playgroud)
然后使用以下数据从前端到/ categories /创建更新语句:
{
firstName: 'A valid firstName'
}
Run Code Online (Sandbox Code Playgroud)
那么安全规则应该通过还是失败?
在参考文档中,它说
开发人员提供的数据显示在request.resource.data中,这是一个包含字段和值的映射.资源中存在的请求中未提供的字段将添加到request.resource.data
相关问题:
{age: 28} 问题3有更多细节(架构问题) 假设你有这样的模型:
interface Category {
firstName: string;
lastName: string;
age?: int;
groupId?: string;
}
Run Code Online (Sandbox Code Playgroud)
现在我们创建一个像这样的安全规则:
match /categories/{document=**} {
allow update: if request.auth.uid != null
&& request.resource.data.firstName is string
&& request.resource.data.lastName is string;
&& request.resource.data.age is int;
&& request.resource.data.groupId is string; …Run Code Online (Sandbox Code Playgroud) 我们的团队构建了一个用于维护的小型 CLI。package.json 指定了属性的路径bin,一切都很好;"bin": { "eddy": "./dist/src/cli/entry.js"}
自动完成是通过使用 来实现的yargs@17.0.1。然而,由于迁移到 Sveltekit,我们最近将项目转换为使用 es6 模块,即 package.json 现在包含type: module. 因此,CLI 现在仅在我们运行以下命令时才有效:
什么有效
node --experimental-specifier-resolution=node ./dist/src/cli/entry.js help
Run Code Online (Sandbox Code Playgroud)
但是,如果我们在没有该标志的情况下运行此命令,则会收到错误“找不到模块”:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module...
Run Code Online (Sandbox Code Playgroud)
所以问题是
我们是否可以以某种方式“始终”将 the 添加experimental-specifier-resolution=node到 CLI - 这样我们就可以继续使用简写eddy并利用自动完成功能?
我的目标是在 Cypress 中编写一个测试,检查元素的宽度是否小于或等于 355px。
我有这个代码,但它只检查确切的尺寸:
cy
.get('.mat-dialog-container:visible')
.should('have.css', 'width', '355px')
Run Code Online (Sandbox Code Playgroud) 我正在努力使用Cypress和Angular Material拖放来测试拖放。因此,目标是将“开始工作”从Todo转移到Done。我创建了以下测试,这应该使您可以轻松重现:
您可以在此处玩Stackblitz 。
describe('Trying to implement drag-n-drop', () => {
before(() => {
Cypress.config('baseUrl', null);
cy.viewport(1000, 600);
cy.visit('https://angular-oxkc7l-zirwfs.stackblitz.io')
.url().should('contain', 'angular')
.get('h2').should('contain', 'To do');
});
it('Should work, based on this https://stackoverflow.com/a/54119137/3694288', () => {
const dataTransfer = new DataTransfer;
cy.get('#cdk-drop-list-0 > :nth-child(1)')
.trigger('dragstart', { dataTransfer });
cy.get('#cdk-drop-list-1')
.trigger('drop', { dataTransfer });
cy.get('#cdk-drop-list-0 > :nth-child(1)')
.trigger('dragend');
cy.get('#cdk-drop-list-1').should('contain', 'Get to work');
});
it('Should work, with this library https://github.com/4teamwork/cypress-drag-drop', () => {
cy.get('#cdk-drop-list-0 > :nth-child(1)')
.drag('#cdk-drop-list-1');
cy.get('#cdk-drop-list-1').should('contain', …Run Code Online (Sandbox Code Playgroud) 如何在新的 Sveltekit 项目中附加 VS Code 调试器?
我在这里创建了一个存储库。
launch.json文件如下所示:
{
"version": "0.2.0",
"configurations": [
{
"type": "pwa-node",
"request": "attach",
"name": "Attach Program",
"processId": "${command:PickProcess}"
}
]
}
Run Code Online (Sandbox Code Playgroud)
当我使用调试器运行项目npm run dev并启动调试器时,它不会中断:
preprocess我尝试在svelte.config.js中添加 sourceMap true :
preprocess: preprocess({
sourceMap: true
}),
Run Code Online (Sandbox Code Playgroud)
当我将鼠标悬停在断点上时,为什么 VS Code 告诉我这是一个“未绑定断点”?
这很令人沮丧,因为我必须调试一些 Sveltekit 代码,而我需要该"request": "attach"选项才能工作
更新
我尝试将开发脚本修改为 "dev": "NODE_OPTIONS=\"--inspect\" svelte-kit dev",但没有帮助...
我正在尝试将赛普拉斯与Angular(v.5)CLI应用程序一起使用.
在本地运行时测试工作正常,因为在这里我可以在运行cypress测试之前启动serve命令.
我尝试按照这里的文档,但没有一个命令似乎工作.
我尝试了varioues组合,看起来像这样:
"cypress:run:report": "./node_modules/.bin/cypress run --record --key <key>",
"cypress:run:ci": "start-server-and-test serve:dev http://localhost:4200 cypress:run:report",
"cypress:run:ci2": "npm run -s serve:dev & npm run -s cypress:run:report",
Run Code Online (Sandbox Code Playgroud)
提前致谢.
使用firebase功能,你可以利用express来实现很好的功能,比如中间件等.我用这个例子来获得如何编写https firebase功能的灵感,由express提供支持.
但是,我的问题是关于如何进行单元测试的官方firebase文档,不包括https-express示例.
所以我的问题是如何对以下函数(打字稿)进行单元测试?:
// omitted init. of functions
import * as express from 'express';
const cors = require('cors')({origin: true});
const app = express();
app.use(cors);
// The function to test
app.get('helloWorld, (req, res) => {
res.send('hello world');
return 'success';
});
exports.app = functions.https.onRequest(app);
Run Code Online (Sandbox Code Playgroud) 当我为 Angular 应用程序编写 Cypress e2e 测试时,我经常使用这样的visit()命令:
.visit('/foo/bar')
这样就完成了工作,即 Cypress 导航到/foo/bar,但整个应用程序会重新加载。这非常慢,并且不会模仿实际的用户行为。
是否可以在不重新加载整页的情况下导航/访问 Angular 应用程序?
我确实尝试过:
cy.window().then((win) => {
win.history.pushState({}, '', '/foo/bar')
})
Run Code Online (Sandbox Code Playgroud)
但是 angular 对此没有反应。
我正在运行一个材质对话框组件的玩笑单元测试,我cdkFocusInitial在对话框中的输入元素上进行了测试。这在运行应用程序时非常有效,但是当我在 Jest 中运行单元测试时,我收到以下错误:
console.warn node_modules/@angular/cdk/bundles/cdk-a11y.umd.js:1861
Element matching '[cdkFocusInitial]' is not focusable. HTMLInputElement {
__zone_symbol__inputfalse: null,
__zone_symbol__blurfalse: null,
__zone_symbol__compositionstartfalse: null,
__zone_symbol__compositionendfalse: null,
__zone_symbol__focusfalse: null,
__zone_symbol__animationstartfalse: null,
[Symbol(SameObject caches)]: [Object: null prototype] { classList: DOMTokenList {} }
}
Run Code Online (Sandbox Code Playgroud)
我试图在 stackblitz 中设置 jest 来重现,但我的组件本质上看起来与官方对话框示例非常相似。我在此处克隆了该示例,并添加了cdkFocusInitial. 当您打开对话框时,焦点按预期设置:
我希望您能帮助弄清楚我可以尝试修复/删除此警告的方法。
解决方法
在 beforeEach 函数中,我像这样模拟 console.warning:
beforeEach(() => {
// Removes "'[cdkFocusInitial]' is not focusable" warning when running tests
console.warn = jest.fn();
});
Run Code Online (Sandbox Code Playgroud) cypress ×4
angular ×3
firebase ×2
angular-cdk ×1
javascript ×1
jestjs ×1
node.js ×1
sveltekit ×1
typescript ×1
yargs ×1