teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

4

1

2018/08/08 00:56

投稿

mahoken
mahoken

スコア85

title CHANGED
File without changes
body CHANGED
@@ -13,52 +13,6 @@
13
13
  ```
14
14
  ajax() method does not exist
15
15
  ```
16
-
17
- ### 該当のソースコード
18
-
19
- * modelSpec.coffee
20
- ```CoffeeScript
21
- _ = require("underscore")
22
- $ = require("jquery")
23
- require("../../../../models/api/Model")
24
-
25
- describe 'model spec', ->
26
- beforeEach ->
27
- @model = new Model();
28
-
29
- it 'Model 定義', -> ---- これは成功する
30
- expect(@model).toBeDefined();
31
-
32
- describe 'fetcheのテスト', () ->
33
- beforeEach ->
34
- spyOn($, 'ajax').and.callThrough() --- エラー発生箇所?
35
-
36
- @model = new Model();
37
- @model.fetch({
38
- success: (model,response,index ) ->
39
- console.log "success!"
40
- error: ->
41
- console.log "error!"
42
- });
43
-
44
- #後処理
45
- afterEach ->
46
- @model = undefined;
47
-
48
- it 'ajaxの戻り値 test', -> --- 失敗する
49
- ajaxCallParams = $.ajax.calls.mostRecent().args[0];
50
- expect( @model.get("status") ).toEqual(0)
51
-
52
- it 'レスポンス値のテスト', ->
53
- expect(_.isEmpty( @model.attributes)).toEqual(false) --- 失敗する
54
- expect(@model.get("msgseq")).toBeDefined()
55
-
56
- expect(true).toBeTruthy()
57
-
58
- return
59
-
60
- ```
61
-
62
16
  ### 試したこと
63
17
  nodeモジュールのrequestを使用してみたが、
64
18
  $.ajax.calls.mostRecent().args[0]
@@ -69,6 +23,5 @@
69
23
  Jasmin-node
70
24
  Backbone.js
71
25
  node.js
72
- CoffeeScript
73
26
 
74
27
  知恵をお貸しください。

3

a

2018/08/08 00:56

投稿

mahoken
mahoken

スコア85

title CHANGED
File without changes
body CHANGED
@@ -3,7 +3,7 @@
3
3
  ######前提
4
4
  1. node.jsについてど素人です。
5
5
  2. Jasmineを使用して、クライアント側のテストコードを作成しています。
6
- 3. 既存のテストコードはRequire.jsで書かれていて、今回node.js書き直しています。
6
+ 3. 既存のテストコードはRequire.jsで書かれていて、node.jsで動くよう書き直しています。
7
7
 
8
8
  ######実現したいこと
9
9
  1. エラーを回避したい

2

一部修正

2018/08/07 08:35

投稿

mahoken
mahoken

スコア85

title CHANGED
File without changes
body CHANGED
@@ -6,7 +6,7 @@
6
6
  3. 既存のテストコードはRequire.jsで書かれていて、今回node.jsに書き直しています。
7
7
 
8
8
  ######実現したいこと
9
- 1. エラーの解決をしたい
9
+ 1. エラーを回避したい
10
10
 
11
11
  ### 発生している問題・エラーメッセージ
12
12
 
@@ -48,12 +48,9 @@
48
48
  it 'ajaxの戻り値 test', -> --- 失敗する
49
49
  ajaxCallParams = $.ajax.calls.mostRecent().args[0];
50
50
  expect( @model.get("status") ).toEqual(0)
51
- expect(ajaxCallParams.dataType).toEqual('json');
51
+
52
- expect(ajaxCallParams.type).toEqual('GET');
53
-
54
52
  it 'レスポンス値のテスト', ->
55
53
  expect(_.isEmpty( @model.attributes)).toEqual(false) --- 失敗する
56
- expect(@model.get("account")).toBeDefined()
57
54
  expect(@model.get("msgseq")).toBeDefined()
58
55
 
59
56
  expect(true).toBeTruthy()

1

初心者マーク付与

2018/08/06 09:10

投稿

mahoken
mahoken

スコア85

title CHANGED
File without changes
body CHANGED
File without changes