2017年1月7日のブックマーク (9件)

  • How to access body of post request in app script using doPost(request)

    kent-where-the-light-is
    kent-where-the-light-is 2017/01/07
    “function doPost(request) { var jsonString = request.postData.getDataAsString(); var jsonData = JSON.parse(jsonString); sheet.appendRow([ 'Data1:' , jsonData.Data1 ]); // Just an example }”
  • How to create JSON string in JavaScript?

    kent-where-the-light-is
    kent-where-the-light-is 2017/01/07
    “Javascript doesn't handle Strings over multiple lines. You will need to concatenate those: var obj = '{' +'"name" : "Raj",' +'"age" : 32,' +'"married" : false' +'}';”
  • Mocha + Chai.js unit testing for ES6 with Istanbul code coverage

    Testing is very important for finding bugs, verifying the functionality and improving the general stability of a piece of software. Almost all (if not all) developers test their code in some way. One way to test would be to manually run the program and try out all the functions to see if everything is working as expected. Another (and better) way is to write automated tests that are run every time

    Mocha + Chai.js unit testing for ES6 with Istanbul code coverage
    kent-where-the-light-is
    kent-where-the-light-is 2017/01/07
    “describe('Rectangle', () => { describe('#width', () => { let rectangle; beforeEach(() => { // Create a new Rectangle object before every test. rectangle = new Rectangle(10, 20); }); it('returns the width', () => { // This will fail if "rectangle.width" does // not equal 10.”
  • Babel6でMochaとChaiを使ったテストを書く - Qiita

    はじめに 最近Reactとか触っています。Github上とかでいろいろなコードを見させていただくのですが、React周辺はReduxを使っているのでBabel使ってるけど、テストはFacebookのJestを使っていてあんまりBabel使えてなかったり、もはやテスト書いてなかったりします。 そもそもReactフロントエンドのライブラリなので、あまりテストを書きたくなくなるのもわかります。ですが、Railsやっててもなるべくテストを書くことを尊重する雰囲気になってきているので、React周辺でもテストを書いていきたいのです。そこで、JestではなくてMochaとChaiを使ってテストを書くにはどうするべきなのかと思い、まとめました。 環境 node: v5.1.0 npm: 3.3.12 ディレクトリ構成 . ├── .babelrc ├── .eslintrc ├── package.j

    Babel6でMochaとChaiを使ったテストを書く - Qiita
    kent-where-the-light-is
    kent-where-the-light-is 2017/01/07
    “Mochaにオプションでコンパイラを渡します。先ほどインストールしたbabel-registerをコンパイラオプションに渡してあげます。 また、テストの記述するファイルをディレクトリ分けするために、--recursiveオプションを指定し
  • Problem: Instructions on mocha testing integration no longer correct with babel 6 · Issue #2685 · babel/babel

    You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

    Problem: Instructions on mocha testing integration no longer correct with babel 6 · Issue #2685 · babel/babel
    kent-where-the-light-is
    kent-where-the-light-is 2017/01/07
    “babel/register is now babel-core/register so try mocha --compilers js:babel-core/register instead”
  • ES6 コードをテストする - アカベコマイリ

    ES6 で書かれたコードをユニット テストしたい。できればテスト自体も ES6 で。という希望を実現してくれそうなツールがあったので試してみる。 mocha ユニット テストには mocha を利用する。業務で Node モジュールのテストに利用していて馴染みがあるのと後述する espower-babel が mocha を想定しているのがその理由。 mocha を npm test や npm run から利用するならインストールはローカルだけでよい。package.json 管理下にある npm にはパスが通った状態になる。 余談だが以下の記事を読んで gulp などもローカルにインストールして実行を npm で抽象化するほうがよいのでは?と考えるようになった。 npm で依存もタスクも一元化する 記事中にもメリットとして説明されているとおり利用者は npm だけ覚えればよい。グローバ

    kent-where-the-light-is
    kent-where-the-light-is 2017/01/07
    “espower-babel は ES6 で書かれたコードとユニット テストを実行するための機能を提供してくれる。使い方は以下の記事が参考になる。 GitHub power-assert-js/espower-babel Web Scratch ライブラリをES6で書いて公開する所から始めよう テ
  • Yarn global command not working

    I'm working with Yarn v0.16.1. If I understand correctly (according to the documentation), yarn global add <package> should be the equivalent of npm install -g <package>. However, when I run the example in the docs (with create-react-app), the command runs successfully but create-react-app is then not available from the command line. Here's the output: $ yarn global add create-react-app $ yarn glo

    Yarn global command not working
    kent-where-the-light-is
    kent-where-the-light-is 2017/01/07
    “you should add export PATH="$PATH:$(yarn global bin)" to your ~/.bash_profile or whatever you use, it would solve the issue. depending on how you installed it, global folder varies for some reason. you can follow this issue here”
  • react-router で ルーティング | スマホ神 – JavaScript 受託開発 –

    React でルーティングをする react-router を試しました。 インストール Browserify + Babel でコンパイルするのでそのツールを Reactreact-router と一緒にインストールしておきます。 $ npm install -g browserify $ npm install -D babelify babel-preset-es2015 babel-preset-react $ npm install -S react react-dom react-router Hello, World! とりあえず画面になにか表示するところからやってみます。 import React, { Component } from 'react'; import { render } from 'react-dom'; import { Router, Rout

    kent-where-the-light-is
    kent-where-the-light-is 2017/01/07
    “Router コンポーネントと Route コンポーネントを使います。 history に hashHistory を入れると URLの # 以降を使ってルーティングをします。 browserHistory を使うと URL 全体を使うみたいです。”
  • 「人生経験マウンティング」したがる人たちについての一考察 - いつか電池がきれるまで

    www.news-postseven.com news.biglobe.ne.jp この石田衣良さんの言葉を読んで、僕もなんだかすごく嫌な気分になったんですよね。 『君の名は。』が気に入らないのなら、作品を批判すればいいのに、なんで監督の人生経験を(勝手に想像して)揶揄するのだろう? でも、こういう手合いに、わざわざ新海誠監督が反応してしまっているのをみると、こういう「人生経験マウンティング」みたいなのは、やられたほうには、けっこう「効く」のも事実なんですよね。 少なくとも、僕はイヤだな、それが事実であろうがなかろうが。 記憶のなかに手を突っ込まれて、かき回されるだけで不快です。 そもそも、世の中の大部分の人は、一般的に「青春時代」と言われているような年代における自分の経験に、満足しているわけではないと思うし。 まあ、こういう「人生経験マウンティング」って、石田さんの「芸風」ではあるんです

    「人生経験マウンティング」したがる人たちについての一考察 - いつか電池がきれるまで
    kent-where-the-light-is
    kent-where-the-light-is 2017/01/07
    寺山修司が「卑怯者ってのはね、 きみが何をしたか、 ってことで決まるんじゃなくて、 きみが何を後悔してるかってことで決まるんだよ」って言ってたのは、すごい俯瞰できた視点なんだなって感想が浮かんだ。