{"id":418,"date":"2021-02-19T15:09:27","date_gmt":"2021-02-19T06:09:27","guid":{"rendered":"https:\/\/www.opentone.co.jp\/optonlabos\/?p=418"},"modified":"2025-05-12T10:06:22","modified_gmt":"2025-05-12T01:06:22","slug":"jasmine%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%88%e3%81%86%ef%bc%81","status":"publish","type":"post","link":"https:\/\/www.opentone.co.jp\/ot-lab\/all\/uncategorized\/jasmine%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%88%e3%81%86%ef%bc%81","title":{"rendered":"Jasmine\u3092\u4f7f\u3063\u3066\u307f\u3088\u3046\uff01"},"content":{"rendered":"\n<p>\u3053\u3093\u306b\u3061\u306f\uff01ishiB\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306fJavascript\u306e\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u300cJasmine\u300d\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>Jasmine\u306f\u3001RSpec\uff08<a href=\"http:\/\/rspec.info\/\">http:\/\/rspec.info\/<\/a>\uff09\u306b\u8fd1\u3044\u8a18\u6cd5\u3092\u4f7f\u3063\u3066JavaScript\u306e\u30c6\u30b9\u30c6\u30a3\u30f3\u30b0\u3092\u884c\u3046\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3059\u3002<\/p>\n\n\n\n<p>Jasmine\u306f\uff08<a href=\"https:\/\/github.com\/pivotal\/jasmine\/downloads\">https:\/\/github.com\/pivotal\/jasmine\/downloads<\/a>\uff09\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3067\u306f\u65e9\u901f\u5b9f\u969b\u306bJasmine\u3092\u4f7f\u3063\u3066\u3001\u30c6\u30b9\u30c8\u3092\u3057\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u306e\u69cb\u6210\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"442\" height=\"384\" src=\"https:\/\/www.opentone.co.jp\/optonlabos\/wp-content\/uploads\/sites\/11\/2021\/02\/20120923_01.gif\" alt=\"\" class=\"wp-image-419\" \/><\/figure>\n\n\n\n<p>\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u306b\u306f\u30b5\u30f3\u30d7\u30eb\u30d5\u30a1\u30a4\u30eb\u3082\u5165\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u4eca\u56de\u306f\u305d\u308c\u3092\u3082\u3068\u306b\u8aac\u660e\u3057\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u305d\u308c\u3067\u306f\u30bd\u30fc\u30b9\u306e\u4e2d\u8eab\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p>\u30c6\u30b9\u30c8\u5bfe\u8c61\u30af\u30e9\u30b9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[javascript]\nfunction Player() {\n}\nPlayer.prototype.play = function(song) {\n  this.currentlyPlayingSong = song;\n  this.isPlaying = true;\n};\n\nPlayer.prototype.pause = function() {\n  this.isPlaying = false;\n};\n\nPlayer.prototype.resume = function() {\n  if (this.isPlaying) {\n    throw new Error(\"song is already playing\");\n  }\n\n  this.isPlaying = true;\n};\n\nPlayer.prototype.makeFavorite = function() {\n  this.currentlyPlayingSong.persistFavoriteStatus(true);\n};\n[\/javascript]<\/pre>\n\n\n\n<p>\u3053\u308c\u306b\u5bfe\u3059\u308b\u30c6\u30b9\u30c8\u30af\u30e9\u30b9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[javascript]\n\/\/ `describe`\u30e1\u30bd\u30c3\u30c9\u306b\u30af\u30e9\u30b9\u7b49\u306e\u30c6\u30b9\u30c8\u5bfe\u8c61\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002\ndescribe(\"Player\", function() {\n  var player;\n  var song;\n\n  beforeEach(function() {\n    player = new Player();\n    song = new Song();\n  });\n\n  \/\/ `it`\u30e1\u30bd\u30c3\u30c9\u306b\u30c6\u30b9\u30c8\u5b9f\u65bd\u5185\u5bb9\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002\n  it(\"should be able to play a Song\", function() {\n\n    \/\/ \u30c6\u30b9\u30c8\u5185\u5bb9\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002\n    player.play(song);\n\n    \/\/ \u671f\u5f85\u5024\u3068\u306e\u6bd4\u8f03\u3092\u884c\u3044\u307e\u3059\u3002\n    expect(player.currentlyPlayingSong).toEqual(song);\n\n    \/\/ \u671f\u5f85\u5024\u3068\u306e\u6bd4\u8f03\u3092\u8907\u6570\u56de\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\uff08\u4e00\u3064\u3067\u3082\u671f\u5f85\u5024\u306b\u4e00\u81f4\u3057\u306a\u3044\u5834\u5408\u306fNG\uff09\u3002\n    expect(player).toBePlaying(song);\n  });\n\n  \/\/ `describe`\u30e1\u30bd\u30c3\u30c9\u306e\u4e2d\u306b`describe`\u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002\n  describe(\"when song has been paused\", function() {\n    beforeEach(function() {\n      player.play(song);\n      player.pause();\n    });\n\n    \/\/ \u4e0a\u8a18\u3068\u540c\u3058\u3088\u3046\u306b`it`\u30e1\u30bd\u30c3\u30c9\u306b\u30c6\u30b9\u30c8\u5185\u5bb9\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002\n    it(\"should indicate that the song is currently paused\", function() {\n      expect(player.isPlaying).toBeFalsy();\n\n      \/\/ demonstrates use of 'not' with a custom matcher\n      expect(player).not.toBePlaying(song);\n    });\n\n    it(\"should be possible to resume\", function() {\n      player.resume();\n      expect(player.isPlaying).toBeTruthy();\n      expect(player.currentlyPlayingSong).toEqual(song);\n    });\n  });\n\n  \/\/ demonstrates use of spies to intercept and test method calls\n  it(\"tells the current song if the user has made it a favorite\", function() {\n    spyOn(song, 'persistFavoriteStatus');\n\n    player.play(song);\n    player.makeFavorite();\n\n    expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);\n  });\n\n  \/\/demonstrates use of expected exceptions\n  describe(\"#resume\", function() {\n    it(\"should throw an exception if song is already playing\", function() {\n      player.play(song);\n\n\/\/ \u7570\u5e38\u7cfb\u306e\u30c6\u30b9\u30c8\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002\n      expect(function() {\n        player.resume();\n      }).toThrow(\"song is already playing\");\n    });\n  });\n});\n[\/javascript]<\/pre>\n\n\n\n<p>\u203b\uff11\u3000\u65e5\u672c\u8a9e\u306e\u30b3\u30e1\u30f3\u30c8\u306f\u5f8c\u304b\u3089\u8ffd\u52a0\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u3053\u306e\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<p>SpecRunner.html\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[html]&lt;\/pre&gt;\n&lt;!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/html4\/loose.dtd\"&gt;\n&lt;html&gt;&lt;head&gt;\n &lt;title&gt;Jasmine Spec Runner&lt;\/title&gt;\n\n&lt;link rel=\"shortcut icon\" type=\"image\/png\" href=\"lib\/jasmine-1.2.0\/jasmine_favicon.png\"&gt;\n &lt;link rel=\"stylesheet\" type=\"text\/css\" href=\"lib\/jasmine-1.2.0\/jasmine.css\"&gt;\n &lt;script type=\"text\/javascript\" src=\"lib\/jasmine-1.2.0\/jasmine.js\"&gt;&lt;\/script&gt;\n &lt;script type=\"text\/javascript\" src=\"lib\/jasmine-1.2.0\/jasmine-html.js\"&gt;&lt;\/script&gt;\n\n&lt;!-- \u30c6\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u307f\u307e\u3059 --&gt;\n &lt;script type=\"text\/javascript\" src=\"spec\/SpecHelper.js\"&gt;&lt;\/script&gt;\n &lt;script type=\"text\/javascript\" src=\"spec\/PlayerSpec.js\"&gt;&lt;\/script&gt;\n\n&lt;!-- \u30c6\u30b9\u30c8\u5bfe\u8c61\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u307f\u307e\u3059 --&gt;\n &lt;script type=\"text\/javascript\" src=\"src\/Player.js\"&gt;&lt;\/script&gt;\n &lt;script type=\"text\/javascript\" src=\"src\/Song.js\"&gt;&lt;\/script&gt;\n\n&lt;script type=\"text\/javascript\"&gt;\n (function() {\n var jasmineEnv = jasmine.getEnv();\n jasmineEnv.updateInterval = 1000;\n\nvar htmlReporter = new jasmine.HtmlReporter();\n\njasmineEnv.addReporter(htmlReporter);\n\njasmineEnv.specFilter = function(spec) {\n return htmlReporter.specFilter(spec);\n };\n\nvar currentWindowOnload = window.onload;\n\nwindow.onload = function() {\n if (currentWindowOnload) {\n currentWindowOnload();\n }\n execJasmine();\n };\n\nfunction execJasmine() {\n jasmineEnv.execute();\n }\n\n})();\n &lt;\/script&gt;\n\n&lt;\/head&gt;\n\n&lt;body&gt;&lt;\/body&gt;\n&lt;\/html&gt;\n[\/html]<\/pre>\n\n\n\n<p>\u5b9f\u884c\u7d50\u679c<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"444\" height=\"254\" src=\"https:\/\/www.opentone.co.jp\/optonlabos\/wp-content\/uploads\/sites\/11\/2021\/02\/20120923_021.gif\" alt=\"\" class=\"wp-image-420\" \/><\/figure>\n\n\n\n<p>\u3059\u3079\u3066\u306e\u30c6\u30b9\u30c8\u304c\u6210\u529f\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u30a8\u30e9\u30fc\u304c\u3042\u308b\u5834\u5408\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30fb\u5b9f\u884c\u7d50\u679c\u4e00\u89a7\u753b\u9762\uff08\u30a8\u30e9\u30fc\u306e\u30c6\u30b9\u30c8\u306f\u8d64\u5b57\u3067\u8868\u793a\u3055\u308c\u307e\u3059\uff09<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"445\" height=\"285\" src=\"https:\/\/www.opentone.co.jp\/optonlabos\/wp-content\/uploads\/sites\/11\/2021\/02\/20120923_03.gif\" alt=\"\" class=\"wp-image-421\" \/><\/figure>\n\n\n\n<p>\u30fb\u5b9f\u884c\u8a73\u7d30\u753b\u9762<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"552\" height=\"334\" src=\"https:\/\/www.opentone.co.jp\/optonlabos\/wp-content\/uploads\/sites\/11\/2021\/02\/20120923_04.gif\" alt=\"\" class=\"wp-image-422\" \/><\/figure>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306b\u7c21\u5358\u306bJavascript\u306e\u30c6\u30b9\u30c8\u304c\u5b9f\u65bd\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306e\u8aac\u660e\u3067\u306f\u8a73\u3057\u304f\u89e6\u308c\u307e\u305b\u3093\u304c\u3001Jasmine\u306f\u975e\u540c\u671f\u306a\u52d5\u4f5c\u3082\u30c6\u30b9\u30c8\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u307e\u305fCI\uff08\u7d99\u7d9a\u7684\u30a4\u30f3\u30c6\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\uff09\u306b\u7d71\u5408\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u8208\u5473\u306e\u3042\u308b\u65b9\u306f\u53c2\u8003\u306b\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p>\u3067\u306f\u3067\u306f\uff5e&nbsp;<\/p>\n<div class=\"opent-_2\" style=\"margin-top: 10px;margin-right: 10px;margin-bottom: 10px;margin-left: 10px;\" id=\"opent-308993671\"><a href=\"https:\/\/www.opentone.co.jp\/backlog\/\" aria-label=\"twitter_backlogskt_new\"><img src=\"https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2023\/02\/twitter_backlogskt_new.jpg\" alt=\"\"  srcset=\"https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2023\/02\/twitter_backlogskt_new.jpg 1024w, https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2023\/02\/twitter_backlogskt_new-300x157.jpg 300w, https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2023\/02\/twitter_backlogskt_new-768x401.jpg 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" width=\"384\" height=\"200\"   \/><\/a><\/div>","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\uff01ishiB\u3067\u3059\u3002 \u4eca\u56de\u306fJavascript\u306e\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u300cJasmine\u300d\u3092\u7d39<\/p>\n","protected":false},"author":1,"featured_media":419,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[14],"class_list":["post-418","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-html5javascript",""],"acf":[],"aioseo_notices":[],"uagb_featured_image_src":{"full":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/02\/20120923_01.gif",442,384,false],"thumbnail":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/02\/20120923_01-150x150.gif",150,150,true],"medium":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/02\/20120923_01-300x261.gif",300,261,true],"medium_large":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/02\/20120923_01.gif",442,384,false],"large":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/02\/20120923_01.gif",442,384,false],"1536x1536":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/02\/20120923_01.gif",442,384,false],"2048x2048":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/02\/20120923_01.gif",442,384,false],"engage-mag-carousel-img":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/02\/20120923_01.gif",442,384,false],"engage-mag-carousel-img-landscape":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/02\/20120923_01-442x225.gif",442,225,true],"engage-mag-carousel-large-img":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/02\/20120923_01.gif",442,384,false],"engage-mag-carousel-large-img-landscape":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/02\/20120923_01-442x287.gif",442,287,true],"engage-mag-large-thumb":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/02\/20120923_01.gif",442,384,false],"engage-mag-small-thumb":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/02\/20120923_01-350x220.gif",350,220,true]},"uagb_author_info":{"display_name":"ah106rx4o4","author_link":"https:\/\/www.opentone.co.jp\/ot-lab\/author\/ah106rx4o4"},"uagb_comment_info":0,"uagb_excerpt":"\u3053\u3093\u306b\u3061\u306f\uff01ishiB\u3067\u3059\u3002 \u4eca\u56de\u306fJavascript\u306e\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u300cJasmine\u300d\u3092\u7d39","_links":{"self":[{"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/posts\/418","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/comments?post=418"}],"version-history":[{"count":1,"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/posts\/418\/revisions"}],"predecessor-version":[{"id":423,"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/posts\/418\/revisions\/423"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/media\/419"}],"wp:attachment":[{"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/media?parent=418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/categories?post=418"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/tags?post=418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}