小编the*_*dev的帖子

nodejs mocha suite未定义错误

我试图使用摩卡运行一些测试,但似乎无法克服此错误.

E:\tdd\nodejs\cart>mocha cart.test.js

node.js:201
        throw e; // process.nextTick error, or 'err
              ^
ReferenceError: suite is not defined
    at Object.<anonymous> (E:\tdd\nodejs\cart\cart.test.js:5:1
    at Module._compile (module.js:432:26)
    at Object..js (module.js:450:10)
    at Module.load (module.js:351:31)
    at Function._load (module.js:310:12)
    at Module.require (module.js:357:17)
    at require (module.js:368:17)
    at C:\Users\lex\AppData\Roaming\npm\node_module
    at Array.forEach (native)
    at load (C:\Users\lex\AppData\Roaming\npm\node_
9)
    at Object.<anonymous> (C:\Users\lex\AppData\Roa
in\_mocha:237:1)
    at Module._compile (module.js:432:26)
    at Object..js (module.js:450:10)
    at Module.load (module.js:351:31)
    at Function._load (module.js:310:12)
    at Array.0 (module.js:470:10)
    at EventEmitter._tickCallback (node.js:192:40)
Run Code Online (Sandbox Code Playgroud)

从我从调用堆栈中可以看出问题就在这里cart.test.js:5:1.知道是什么导致了这个吗?

谢谢

cart.js

var GetTotalSum = function (input) { …
Run Code Online (Sandbox Code Playgroud)

javascript tdd mocha.js node.js

28
推荐指数
2
解决办法
1万
查看次数

JQuery附加AJAX

我使用以下脚本加载一些Wordpress帖子.不幸的是,这取代了我的内容,我想附加到现有的内容.

你有什么建议使用AJAX调用追加.

$('#load-posts a').click(function() { 
    if(pageNum <= max) {
        $('#content').load(nextLink + ' article',
            function() {            
                // Update page number and nextLink.
                // Update the button message.                   
                }
            }
        );          
    }
});
Run Code Online (Sandbox Code Playgroud)

谢谢

javascript ajax jquery append

9
推荐指数
2
解决办法
3万
查看次数

如何在Postman Collection Runner中查看回复?

我使用Postman Collection Runner使用迭代多次运行相同的请求.我的测试按预期工作,但我无法看到每个请求的个别响应.

是否可以在Postman Collection Runner中查看请求的响应?

postman postman-collection-runner

9
推荐指数
3
解决办法
1万
查看次数

Inno设置自定义页面

我想在选择安装位置的页面后面创建一个自定义向导页面.

我已经了解了如何创建自定义页面并将其添加到过程中的向导中InitializeWizard.

我的问题是,当我创建自定义页面时,安装位置选择的默认页面不再出现.

我有什么选项来保留默认页面(安装位置选择)并添加我的新自定义页面?

谢谢

我的代码看起来像这样(由inno提供的CodeClasses.iss示例):

procedure CreateTheWizardPages;
var
  Page: TWizardPage;
  Button, FormButton: TButton;
  CheckBox: TCheckBox;
  Edit: TEdit;
  PasswordEdit: TPasswordEdit;
  Memo: TMemo;
  Lbl, ProgressBarLabel: TLabel;
  ComboBox: TComboBox;
  ListBox: TListBox;
  StaticText: TNewStaticText;
  ProgressBar: TNewProgressBar;
  CheckListBox, CheckListBox2: TNewCheckListBox;
  FolderTreeView: TFolderTreeView;
  BitmapImage, BitmapImage2, BitmapImage3: TBitmapImage;
  BitmapFileName: String;
  RichEditViewer: TRichEditViewer;
begin
  { TButton and others }

  Page := CreateCustomPage(wpWelcome, 'Custom wizard page controls', 'TButton and others');

  Button := TButton.Create(Page);
  Button.Width := ScaleX(75);
  Button.Height := ScaleY(23);
  Button.Caption := 'TButton';
  Button.OnClick := @ButtonOnClick;
  Button.Parent …
Run Code Online (Sandbox Code Playgroud)

inno-setup

6
推荐指数
1
解决办法
2万
查看次数

Inno Setup:如何在InitializeWizard过程中使用{app}

如何{app}InitializeWizard程序中获得对变量的访问权限?

当我使用时,ExpandConstant('{app}');我收到下一条错误消息:

"在初始化之前,尝试扩展{app}常量"

inno-setup

6
推荐指数
1
解决办法
5801
查看次数

Shell BrowseForFolder预选路径

我有这个电话:

oShell.BrowseForFolder(Me.hwnd, "Select path:", 0, "C:\dir\")
Run Code Online (Sandbox Code Playgroud)

这将打开一个标准的文件浏览器对话框,其中包含"C:\ dir \".我的问题是你无法在根文件夹上方浏览.(如doc http://msdn.microsoft.com/en-us/library/bb774065(v=vs.85).aspx中所述)

有关使用选定路径和完整浏览可能性对该对话框进行操作的任何建议吗?

谢谢

vb6 winapi shell32.dll

6
推荐指数
2
解决办法
3861
查看次数

Node.js 条件要求

c请考虑最新版本的 Node.js 支持插件。有条件加载它的最佳方法是什么?

module.exports = {
  plugins: [   
    require("a"),
    require("b"),
    [require("c"), { default: false }] //only if node version > 0.11
  ]
};
Run Code Online (Sandbox Code Playgroud)

javascript node.js

6
推荐指数
1
解决办法
8305
查看次数

使用ELK堆栈记录应用程序

使用NLog和Elasticsearch目标将日志转发到AWS Elasticsearch作为服务集群,用于Kibana中的可视化.

这很好但我担心由于ES群集可用性而导致在生产中使用它,以及当使用elasticsearch-net客户端通过HTTP 发送日志时群集故障转移的影响.

我正在考虑为NLog使用不同的目标,将日志发送到更可靠的目的地(文件,S3?),然后让其他东西(Logstash,AWS Lambda)接收它们并将它们发送到ES,这样可以最大限度地降低风险申请本身.

想听听你的想法

UPDATE

主要关注的是应用程序可用性和防止丢失日志使用辅助目标.

使用最新的NLog和throwExceptions设置为false,此时不使用异步目标,但考虑到这一点,因为我们有很多异步代码.

为了给出更多的上下文,"app"是一组API(WebAPI和WCF),它们的速度为10-15K RPM.

脚本

请求进来,ES群集不可用.

案例1 - 没有异步目标的NLog

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
        autoReload="true"
        throwExceptions="false"
        internalLogLevel="Off"
        internalLogFile="c:\temp\nlog-internal.log">

    <targets>
      <target name="elastic"
              xsi:type="BufferingWrapper"
              flushTimeout="5000">
        <target xsi:type="ElasticSearch"
                layout="${logger} | ${threadid} | ${message}"
                index="logstash-${date:format=yyyy.MM.dd}"
                includeAllProperties="true"
                uri="...">

          <field name="user"
                 layout="${windows-identity:userName=True:domain=False}"/>
          <field name="host"
                 layout="${machinename}"/>
          <field name="number"
                 layout="1"
                 layoutType="System.Int32"/>

        </target>
      </target>
    </targets>
    <rules>
      <logger name="*"
              minlevel="Debug"
              writeTo="elastic" />
    </rules>
  </nlog>
Run Code Online (Sandbox Code Playgroud)

问:

  • 当无法到达目标时主线程会发生什么?

案例2 - 具有异步目标的NLog

使用带有queueLimit ="10000"的弹性搜索目标的异步包装程序batchSize ="100"

问:

  • 是另一个线程[B]创建?
  • 后续请求会重用线程[B]并对日志记录请求进行排队吗?
  • 到达queueLimit时会发生什么? …

.net scalability nlog amazon-s3 elastic-stack

6
推荐指数
1
解决办法
4989
查看次数

首次测试(VS2010 C#)

这是我第一次遇到单元测试,我试图理解如何在简单的日期验证中使用这个概念.

用户可以选择代表日期的ToDate,直到可以进行付款.如果我们的日期无效,则无法付款.

    private void CheckToDate(DateTime ToDate)
    {
        if (Manager.MaxToDate < ToDate.Year)
            //show a custom message
    }
Run Code Online (Sandbox Code Playgroud)

在这种情况下如何使用单元测试?

问候,

亚历克斯

谢谢你的回答:

正如你们许多人所建议的那样,我将拆分函数并将验证与消息显示分开,并使用单元测试.

public bool IsDateValid(DateTime toDate)
{
    return (Manager.MaxToDate < toDate.Year);
}
Run Code Online (Sandbox Code Playgroud)

c# unit-testing visual-studio-2010 vs-unit-testing-framework

3
推荐指数
1
解决办法
2113
查看次数

正则表达式:解析街道名称/号码

C#/.NET 2.0

我需要在两个单独的值中解析包含街道名称和房子的字符串.

in: "Streetname 1a"         out:  "streetname"  "1a"
    "Street name 1a"              "street name" "1a"
    "Street name 1 a"             "street name" "1 a"
Run Code Online (Sandbox Code Playgroud)

我的第一选择是将字符串拆分,我找到了一个""字符,但这对第二种情况不起作用.

result[0] = trimmedInput.Substring(0, splitPosition).Trim();
result[1] = trimmedInput.Substring(splitPosition + 1).Trim();
Run Code Online (Sandbox Code Playgroud)

做这个的最好方式是什么?我可以使用正则表达式吗?

谢谢

.net c# regex parsing

3
推荐指数
1
解决办法
1万
查看次数

.NET 4中的Math.Round()行为

可能重复:
在C#中:Math.Round(2.5)结果为2(而不是3)!你在跟我开玩笑吗?
.Net Round Bug

我有一个中间值(number.5),我需要指定如何舍入(上限值或下限值).

我理解的行为Math.RoundMidPointRounding参数,但不解决我的问题:

// To Even
Console.WriteLine(Math.Round(4.4)); // 4
Console.WriteLine(Math.Round(4.5)); // 4
Console.WriteLine(Math.Round(4.6)); // 5
Console.WriteLine(Math.Round(5.5)); // 6

// AwayFromZero
Console.WriteLine(Math.Round(4.4)); // 4
Console.WriteLine(Math.Round(4.5)); // 5
Console.WriteLine(Math.Round(4.6)); // 5
Console.WriteLine(Math.Round(5.5)); // 6

// in one case I need 
Console.WriteLine(Math.Round(4.4)); // 4
Console.WriteLine(Math.Round(4.5)); // 4
Console.WriteLine(Math.Round(4.6)); // 5
Console.WriteLine(Math.Round(5.5)); // 5

// another case I need
Console.WriteLine(Math.Round(4.4)); // 4
Console.WriteLine(Math.Round(4.5)); // 5
Console.WriteLine(Math.Round(4.6)); // 5
Console.WriteLine(Math.Round(5.5)); // 6
Run Code Online (Sandbox Code Playgroud)

c# math rounding .net-4.0

1
推荐指数
2
解决办法
5344
查看次数