我正在尝试使用babel,jest和vs代码调试一个简单的项目.当我设置一个断点然后开始调试时,我的断点会跳转并且不再是我开始时的位置.可以在这里看到样本回购 - https://github.com/RyanHirsch/starter-node
我已经更新了我launch.json的内容
{
"name": "Jest",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
"stopOnEntry": false,
"args": ["-i", "${file}"],
"cwd": "${workspaceRoot}",
"runtimeExecutable": null,
"sourceMaps": true,
"protocol": "inspector"
}
Run Code Online (Sandbox Code Playgroud)
我.babelrc看起来像:
{
"plugins": ["@babel/plugin-proposal-object-rest-spread"],
"sourceMaps": "inline",
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "6.10"
}
}
]
]
}
Run Code Online (Sandbox Code Playgroud)
我认为源映射选项足以让它工作但我错了.需要更改什么才能将断点保留在原始位置?特别是在尝试调试我的测试时.
====编辑====
在断点位于测试线10和实施线4之前:
当我通过选择我的测试文件开始调试然后在VS Code调试窗格中运行Jest时,我的断点跳转到测试第9行和实现第6行:

在节点9.6.1上运行,具有以下扩展名:
DavidAnson.vscode-markdownlint
EditorConfig.EditorConfig
Orta.vscode-jest
PKief.material-icon-theme
PeterJausovec.vscode-docker
Shan.code-settings-sync
bungcip.better-toml
dbaeumer.vscode-eslint
dracula-theme.theme-dracula
dzannotti.vscode-babel-coloring
eamodio.gitlens
esbenp.prettier-vscode
gerane.Theme-FlatlandMonokai
humao.rest-client
mauve.terraform
mikestead.dotenv
mjmcloug.vscode-elixir
mohsen1.prettify-json
ms-vscode.Theme-MaterialKit
ms-vscode.azure-account
ms-vscode.cpptools
ritwickdey.LiveServer
sbrink.elm …Run Code Online (Sandbox Code Playgroud) 我遇到了一个带有replace的自定义指令的问题:true,
http://jsbin.com/OtARocO/2/edit
据我所知,我只有一个根元素,我的,这里发生了什么?
Error: Template must have exactly one root element. was:
<tbody>
<tr><td>{{ item.name }}</td></tr>
<tr><td>row2</td></tr>
</tbody>
Run Code Online (Sandbox Code Playgroud)
使用Javascript:
var app = angular.module("AngularApp", [])
.directive('custom', [function () {
return {
restrict: 'E',
replace: true,
templateUrl: 'lineItem.html',
link: function(scope, element, attrs) {
}
};
}])
.controller('MyCtrl', ['$scope', function($scope) {
$scope.items = [
{
name: 'foo'
},
{
name: 'bar'
},
{
name: 'baz'
}
];
}]);
Run Code Online (Sandbox Code Playgroud)
HTML:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<meta name="description" content="Angular Avatar Example" />
<script src="//crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/md5.js"></script> …Run Code Online (Sandbox Code Playgroud) 我正在进行单元测试,感觉我做错了.我有一个'主'对象有很多关系
author: belongsTo('person', { async: true }),
title: attr('string'),
category: belongsTo('category', { async: true }),
impact: belongsTo('impact', { async: true }),
status: attr('string'),
createdDate: attr('moment'),
submittedDate: attr('moment'),
authorOrg: belongsTo('organization', { async: true }),
locations: hasMany('location', { async: true }),
audits: hasMany('audit', { async: true })
Run Code Online (Sandbox Code Playgroud)
每次我在单元测试及其相关项目的工作时间(person,category,impact),我有重现所有的needs,我的"主"对象有值.category当我只关心字符串的名称及其与'main'对象之间的关系时,我觉得我的位置单元测试不合适
// location/model-test.js
import {
moduleForModel,
test
} from 'ember-qunit';
moduleForModel('location', 'Location', {
// Specify the other units that are required for this test.
needs: …Run Code Online (Sandbox Code Playgroud) 跟随入门指南我有这个http://jsbin.com/enutit/2/edit
我的问题是我怎么不能从这个帮助器中删除itemController
<ul id="todo-list">
{{#each controller itemController="todo"}}
<li {{bindAttr class="isCompleted:completed isEditing:editing"}}>
Run Code Online (Sandbox Code Playgroud)
然后添加
itemController: 'todo',
Run Code Online (Sandbox Code Playgroud)
到Todos.TodosController并让它工作?
我正在使用Dragula在Ember中创建一组拖放组件.我将项目列表传递给包含多个可丢弃存储桶的父包装器.最初过滤此项目列表,以便它们在正确的存储桶中呈现正确的项目.然后将Dragula连接起来,以便可以拖放项目.当发生drop事件时,我尝试更新底层的Ember对象.这可能导致重新应用过滤器并进行一些渲染.问题是DOM已被Dragula操纵,并且与Ember认为它应该是不同的并且DOM节点刚刚消失.
当他们认为自己拥有DOM及其当前代表时,我怎么能让Ember和Dragula玩得很好?我已经尝试取消了draggle drop事件,然后让Ember设置了有限的成功值.
dnd-wrapper/template.hbs
{{yield (action "register")}}
Run Code Online (Sandbox Code Playgroud)
dnd-wrapper/component.js
export default Ember.Component.extend({
drake: null,
buckets: [],
items: [],
initDragula: Ember.on('willInsertElement', function() {
this.set('drake', window.dragula());
}),
setupDragulaEvents: Ember.on('didInsertElement', function() {
this.get('drake').on('drop', (itemEl, destinationEl, sourceEl) => {
let dest = this.buckets.findBy('element', destinationEl);
let source = this.buckets.findBy('element', sourceEl);
let item = this.items.findBy('element', itemEl);
item.component.set('item.bucket', dest.component.get('value'));
});
}),
actions: {
register(type, obj) {
if(type === 'bucket') {
this.get('drake').containers.push(obj.element);
this.buckets.pushObject(obj);
}
else {
this.items.pushObject(obj);
}
}
}
});
Run Code Online (Sandbox Code Playgroud)
dnd-bucket/template.hbs
<h2>bucket {{value}}</h2>
<ul>
{{#each filteredItems as |item|}} …Run Code Online (Sandbox Code Playgroud) 我有以下jsbin:http://jsbin.com/okoxim/4/edit
filteredContent是一个计算属性,用于过滤Controller的内容.我想知道如何对计算属性进行排序以及我可以改进代码的任何方法.
App.StudentsController = Ember.ArrayController.extend({
sortProperties: ['name'],
nameFilter: null,
filteredContent: function(){
if(!this.get('nameFilter')) return this.get('content');
var nameRegEx = new RegExp(this.get('nameFilter'), 'i');
return this.filter(function(item) {
return item.get('name').search(nameRegEx) !== -1;
});
}.property('nameFilter', '@each.name')
});
Run Code Online (Sandbox Code Playgroud) 我试图使用两者grunt-express-server,grunt-contrib-watch然而,一旦我的快递服务器启动,它似乎不再做任何观看或重新加载.我有服务器设置在后台生成.我的项目在这里:https://github.com/RyanHirsch/firem
这是我的Gruntfile.js
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
// Project configuration.
grunt.initConfig({
watch: {
options: {
livereload: true,
},
express: {
files: [ 'index.html', 'server.js' ],
tasks: [ 'express:dev' ],
options: {
spawn: false
}
}
},
express: {
options: {
// Override defaults here
},
dev: {
options: {
script: 'server.js'
}
}
}
});
grunt.registerTask('default', ['express:dev','watch']);
};
Run Code Online (Sandbox Code Playgroud) ember.js ×4
angularjs ×1
babel-jest ×1
babeljs ×1
dom ×1
dragula ×1
ember-cli ×1
express ×1
gruntjs ×1
javascript ×1
jestjs ×1
jquery ×1
unit-testing ×1