小编Pat*_*ane的帖子

在使用Vuex时如何测试Vuejs组件

我正在为更大的应用程序中的vuejs组件编写单元测试.我的应用程序状态全部在vuex存储中,因此几乎所有组件都从vuex中提取数据.

我找不到为此编写单元测试的工作示例.我已经找到

Evan You说的地方:

单独测试组件时,可以使用store选项将模拟存储直接注入组件.

但我找不到如何测试这些组件的好例子.我尝试了很多方法.以下是我见过人们做的唯一方法.stackoverflow问答

基本上它看起来像

test.vue:

 <template>
    <div>test<div>
 </template>
 <script>
 <script>
    export default {
        name: 'test',
        computed: {
            name(){
                return this.$store.state.test;
            }
        }
    }
  </script>
Run Code Online (Sandbox Code Playgroud)

test.spec.js

import ...

const store = new Vuex.Store({
  state: {
    test: 3
  }
});
describe('test.vue', () => {

  it('should get test from store', () => {

    const parent = new Vue({
      template: '<div><test ref="test"></test></div>',
      components: { test },
      store: store
    }).$mount();

    expect(parent.$refs.test.name).toBe(3);
  });
}
Run Code Online (Sandbox Code Playgroud)

注意"ref"这个例子没有它就行不通.

这真的是正确的方法吗?看起来它会变得很乱,因为它需要将道具添加到模板中作为字符串.

Evan的引用似乎暗示商店可以直接添加到子组件(即不像示例那样的父组件).

你是怎样做的?

components unit-testing vue.js vuex

8
推荐指数
1
解决办法
1845
查看次数

Swift_TransportException·无法与主机smtp.sendgrid.net建立连接[连接超时#110]

我正在使用Laravel 4.2,它使用swiftmailer lib来发送电子邮件.我正在尝试使用Sendgrid SMTP服务,但我在登台服务器上收到超时错误.

在我的本地开发中一切正常.

mail.php

return array(
    'driver' => 'smtp',
    'host' => 'smtp.sendgrid.net',
    'port' => 587,
    'encryption' => 'tls',
    'username' => 'username'
    'password' => ...
Run Code Online (Sandbox Code Playgroud)

我已切换到端口465和'ssl',在本地工作,但在服务器上没有运气.服务器上启用了OpenSSL.

有趣的是Mandrill smtp(它使用不同的laravel驱动程序),本地服务器smtp在服务器上正常工作.

港口是开放的.我可以从服务器telnet到sendgrid.我还将IPv4的主机名切换为仅用于检查,因为人们使用smtp.gmail.com IPv4与IPv6的所有麻烦.没有什么区别.

具体的错误位置是这样的:

    $this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext);
    if (false === $this->_stream) {
        throw new Swift_TransportException(
            'Connection could not be established with host '.$this->_params['host'].
            ' ['.$errstr.' #'.$errno.']');
Run Code Online (Sandbox Code Playgroud)

所以我的问题是我应该检查一下为什么swiftmailer和stream_socket_client php函数在本地工作但不在服务器上工作.本地我在mac上,服务器正在运行centOS.

php email swiftmailer sendgrid

5
推荐指数
1
解决办法
8587
查看次数

Netsuite 脚本 beforeLoad 记录未被修改

我试图在用户打开采购订单时修改它。这似乎是一个非常简单的例子,但似乎不起作用。在 GUI 中我没有看到“测试”备忘录。在脚本调试中,备注字段为空。

由于调试,我知道脚本正在运行。

/**
 * Update Drop Ship PO with route Information
 *
 * @author Patrick 
 * @NApiVersion 2.0
 * @NScriptType UserEventScript
 */


define(['N/search', 'N/record'],

    function(search, record) {
        function beforeLoad(context) {
            var newRecord = context.newRecord;
            newRecord.setValue({fieldId: 'memo', value: 'this is a test'});
            log.debug({title: 'memo', details: newRecord.getValue({fieldId: 'memo'})});

            return true;
        }
      return {
        beforeLoad: beforeLoad
    };
});
Run Code Online (Sandbox Code Playgroud)

我假设它与我可以修改的记录有关,但我一生都无法在文档中找到有效的示例。任何帮助将不胜感激。

javascript oracle netsuite suitescript

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

Netsuite 脚本:是什么导致 THAT_RECORD_IS_NOT_EDITABLE 错误?

我正在尝试使用 netsuite 脚本 v2 修改运输订单记录。

 * @NApiVersion 2.0
 * @NScriptType UserEventScript
 */


define(['N/search', 'N/record'],

    function(search, record) {
        function afterSubmit(context) {
            if (context.type !== context.UserEventType.CREATE){
                 return;
            }

            try {
              // Get the current Record
              var salesOrder = context.newRecord;
              salesOrder.setValue({fieldId: 'custbody_route_vendor', value: 1});
              salesOrder.save({enableSourcing: true, ignoreMandatoryFields: true});

            } catch (error) {
              log.error({title: 'Error: ', details: error });
            }

        }

    return {
        afterSubmit: afterSubmit
    };
});
Run Code Online (Sandbox Code Playgroud)

这似乎很简单。但是当我保存销售订单时,它会引发此错误:

{"type":"error.SuiteScriptError","name":"THAT_RECORD_IS_NOT_EDITABLE","message":"该记录不可编辑。","stack":["createError(N/error)...

这不是很有帮助,因为我不知道哪些类型的东西会使记录无法编辑。

我搜索了文档和互联网,但找不到此错误的参考。该保存功能的文档没有解决可能的错误:

https://system.na2.netsuite.com/app/help/helpcenter.nl?fid=section_4267286323.html

任何建议都会非常有帮助。

javascript oracle netsuite

0
推荐指数
1
解决办法
1509
查看次数

Netsuite客户端脚本仅在测试模式下执行

我有一个简单的客户端脚本,可以在测试模式下正常工作。但是一旦我部署它,它就会停止执行。

/**
 * @author Patrick 
 * @NApiVersion 2.x 
 * @NScriptType ClientScript
 */
define(['N/ui/message', 'N/record'],
    function(message, record) {

        function pageInit(context) {
            var purchaseOrder = context.currentRecord;
            log.debug(purchaseOrder);

            return true;
        }

        return {
          pageInit: pageInit
        }
    }
);
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

此部署有效。但是,一旦我将其切换到部署状态,它将停止工作。关于我所缺少的任何建议都会有很大的帮助。谢谢。

javascript oracle netsuite suitescript2.0

0
推荐指数
1
解决办法
37
查看次数