この記事は、はてなエンジニアアドベントカレンダー2016の5日目の記事です。 こんにちは、はてなでアプリケーションエンジニアをしている id:shiba_yu36 です。先日、buildersconにおいて、現在所属しているプロジェクトでJavaScriptのユニットテストを導入した知見について、「一から始めるJavaScriptユニットテスト」というタイトルで発表しました。 speakerdeck.com この発表は、実際にJavaScriptのユニットテスト環境を作ってみると非常にハードルが高いと感じたので、そのハードルを少しでも下げられればという思いで、非常にシンプルな例で一から環境を作る例を紹介しました。アジェンダは次のとおりでした。 カクヨムのJS環境 JSのテストツールを整理する 通常の関数のユニットテスト DOM操作する機能のユニットテスト カクヨムのJS環境や、JSのテスト
When we talked about Housing Go at JSFoo, there were a lot of queries about how we maintain the performance of our app over the time. Below is a description of how we do it. We started development of Housing Go with the focus on metrics like sizes of the chunks generated using Webpack, Time to First Byte, First Paint, Speed Index etc. We knew to keep the app performant we have to make sure that we
I get really excited about new tech I find interesting. When I first “got” the testing framework AVA, I was soooo excited. I was on the rooftops of twitter telling people to give AVA a shot. I created two screencasts about how to set up and use AVA, and a full blown workshop on how to test React with AVA: So, I convinced my team at PayPal and we started using AVA for all our new React tests. I was
First of all, we would like to thank everyone who’s reading this for your interest and support for TestCafe. And we especially appreciate those of you who reached us to say thank you, offer help or share feedback. Let’s keep building a better testing framework together! So, here is our first minor update and that’s what it includes. Enhancements Snapshot API shorthands Previously, if you needed to
TestCafeという自動テストフレームワーク(いわゆるE2Eテストフレームワークジャンルとしておきます)を試してみました。 TestCafeの特徴としては、Seleniumを使っていないこと、設定ファイルなしで利用できる点です。 Seleniumを使ったテストフレームワークとしては、Protractor、testium、WebdriverIOなどがあります。 (Seleniumを使わない他のテストフレームワークだとNightmareなど) Seleniumを使わずにどうやって自動的にブラウザを操作するかというと、中継サーバーを起動してそこにテストコードなどを追加して動かすことができるSelenium RC(1)方式に近いものだと思います。 同名のウェブサービス/クライアントアプリも出していて、こちらはSelenium IDEのようにGUIで操作して記録したものを再生などができます。 なぜ
はじめに みなさん、日頃JavaScriptのテストはどのように行っていますか? 昨今ではAngularJSやReactJSを始め、JavaScriptのフレームワークやライブラリを使用してのフロントエンドの開発が当たり前のようになってきております。 ではそのフロントエンド、JavaScriptのテストはどんなツールを使っていますか? mochaやpower-assert、chai、Karma、Jasmine等を組み合わせて使用してテストしているでしょうか。 前置きが少し長くなりましたが、Facebookが開発したオールインワンな「Jest」というツールのReactでのHowto的な使い方から実際のテストでの使用例を交えて紹介したいと思います。 ちなみにこのJest、最近リリースされて話題になったパッケージ管理のYarnでも使われています。 対象バージョン Jest:22.0.4 Reac
Illustration by Sue Lockwood TC-39, the standards body that defines JavaScript, maintains a gigantic suite of tests for the language. The name of that test suite is Test262. When we started extending Test262 to cover brand new language features, we knew we were in for some surprises. Even so, we never could have anticipated the horrors we would uncover. JavaScript is a powerful language. The abstr
JavaScript の型チェックといえば Flow や TypeScript だが前者は型の定義ファイルが必要、後者は言語自体を拡張しているため導入コストが少々、高い。もっと手軽に 追加の外部ファイルは不要 JavaScript の組み込み型ぐらいをチェックできればよい ぐらいのものがあれば、と探してみたら azu/jsdoc-to-assert がそんな感じなので試してみる。 2016/8/24 「省略可能な引数」と「null 許容型」の項を追記 jsdoc-to-assert jsdoc-to-assert は JSDoc 形式で書かれた関数のコメントを元に型チェックする。開発の経緯や詳細については JSDocをランタイムassertに変換するBabelプラグインを書いた | Web Scratch を参照のこと。処理は単純で、 JSDoc の @param から引数の型と名前を取得
IntroductionGenerative testing is a widespread approach in the functional world, mainly due to the popularity of Haskell’s QuickCheck and Clojure’s QuickCheck implementation test.check. Traditional unit tests enable us to verify assumptions for a given function. This approach, also known as example based testing, is based on manually defined inputs and expected outputs. In other words a developer
Promises are a great way of doing async programming. But testing with promises can be a bit cumbersome, even with the use of the arrow functions syntax. Recently I've found a small and nice package to help to stub tests using Sinon, and the library is sinon-stub-promise. function fetchMovieData() { return fetch("/movies") .then(res => { return res.json(); }) .then(movies => { return movies; }); }
Debunk the myth that JavaScript is not easily testable. Whether you use Node.js, Express, MongoDB, jQuery, AngularJS, or directly manipulate the DOM, you can test-drive JavaScript. Learn the craft of writing meaningful, deterministic automated tests with Karma, Mocha, and Chai. Test asynchronous JavaScript, decouple and properly mock out dependencies, measure code coverage, and create lightweight
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く