-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
333 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
# QUnit 2.xで変わること | ||
|
||
#  | ||
---- | ||
|
||
# QUnit 2.xで変わること | ||
|
||
## 現バージョン: QUnit 1.16.0 | ||
|
||
----- | ||
|
||
# 基本方針 | ||
|
||
- 2.0 では互換レイヤーを入れて互換性を維持 | ||
- 既存のメソッド名の変更もDeprecatedだが動く | ||
- 2.1で互換レイヤーを破棄して完全に移行 | ||
- 詳しくは [QUnit 2.x Upgrade Guide | QUnit](http://qunitjs.com/upgrade-guide-2.x/ "QUnit 2.x Upgrade Guide | QUnit") を読む | ||
|
||
----- | ||
|
||
# Try Own | ||
|
||
- [azu/qunit-examples](https://github.com/azu/qunit-examples "azu/qunit-examples") | ||
- 今回でてきたサンプルコード | ||
|
||
---- | ||
|
||
# Avoid Global | ||
|
||
- グローバルに合ったものが`Qunit.*`に移動 | ||
|
||
```js | ||
// OLD Style | ||
module("module name"); | ||
test("old test", function (assert) { | ||
expect(1);// 1つのassertがあるという宣言 | ||
assert.ok(true); | ||
}); | ||
``` | ||
|
||
----- | ||
|
||
# Avoid Global | ||
|
||
- グローバルに合ったものが`Qunit.*`に移動 | ||
|
||
```js | ||
// NEW Style | ||
QUnit.module("module name"); | ||
QUnit.test("new test", function (assert) { | ||
assert.expect(1);// 1つのassertがあるという宣言 | ||
assert.ok(1); | ||
}); | ||
``` | ||
|
||
|
||
------ | ||
|
||
# Avoid Global | ||
|
||
deepEqual(), equal(), notDeepEqual(), notEqual(), notPropEqual(), notStrictEqual(), ok(), propEqual(), strictEqual(), throws() | ||
|
||
などのassertionも`assert.*`に移動 | ||
|
||
------ | ||
|
||
# `done`での非同期テストの導入 | ||
|
||
- `asyncTest`や`start`などはDeprecatedに | ||
|
||
```js | ||
asyncTest("old async test", function (assert) { | ||
setTimeout(function () { | ||
assert.ok(true); | ||
start(); | ||
}, 16); | ||
}); | ||
``` | ||
|
||
|
||
------ | ||
|
||
# `done`での非同期テストの導入 | ||
|
||
|
||
- `assert.async`の返り値が`done`関数 | ||
- `asyncTest`という宣言は不要 | ||
|
||
```js | ||
QUnit.test("new async test", function (assert) { | ||
var done = assert.async(); | ||
setTimeout(function () { | ||
assert.ok(1); | ||
done(); | ||
}, 16); | ||
}); | ||
``` | ||
|
||
|
||
----- | ||
|
||
# setup/teardown のリネーム | ||
|
||
- setup/teardown が beforeEach/afterEach にリネーム | ||
|
||
```js | ||
QUnit.module( "router", { | ||
setup: function( assert ) { | ||
this.router = new Router(); | ||
}, | ||
teardown: function( assert ) { | ||
this.router.destroy(); | ||
} | ||
}); | ||
``` | ||
|
||
---- | ||
|
||
# setup/teardown のリネーム | ||
|
||
- setup/teardown が beforeEach/afterEach にリネーム | ||
|
||
```js | ||
QUnit.module( "router", { | ||
beforeEach: function( assert ) { | ||
this.router = new Router(); | ||
}, | ||
afterEach: function( assert ) { | ||
this.router.destroy(); | ||
} | ||
}); | ||
``` | ||
|
||
|
||
---- | ||
|
||
# Promiseサポート | ||
|
||
- MochaやBuster.jsなどで採用されてるスタイル | ||
- `reutrn promise;`というかんじで[Thenable](http://azu.github.io/promises-book/ "Thenable")を返すと認識 | ||
|
||
```js | ||
QUnit.test("fulfilled Promise", function (assert) { | ||
return Promise.resolve("value").then(function (value) { | ||
assert.equal(value, "value") | ||
}); | ||
}); | ||
``` | ||
|
||
|
||
|
||
----- | ||
|
||
# Promiseテスト | ||
|
||
- `assert.expect`が動く!(利用assert数を宣言する機能) | ||
- [意図しないテスト結果](http://azu.github.io/promises-book/#mocha-promise "意図しないテスト結果") となるのを宣言で防止出来る | ||
|
||
```js | ||
QUnit.test("fulfilled Promise", function (assert) { | ||
assert.expect(1);// it's work! | ||
return Promise.resolve("value").then(function (value) { | ||
assert.equal(value, "value") | ||
}); | ||
}); | ||
``` | ||
|
||
---- | ||
|
||
# Promiseテスト | ||
|
||
- `assert`がひとつも呼ばれないテストは自動で失敗する! | ||
- Promiseテストのミスがかなり軽減される GREATE! | ||
|
||
```js | ||
QUnit.test("Year! Fail test", function (assert) { | ||
// `resolve`なので`catch`は呼ばれない | ||
return Promise.resolve().catch(function (value) { | ||
assert.equal(value, "value") | ||
}); | ||
}); | ||
``` | ||
|
||
|
||
---- | ||
|
||
# レポーターの標準化 | ||
|
||
- [js-reporters/js-reporters](https://github.com/js-reporters/js-reporters "js-reporters/js-reporters") | ||
- テストフレームワークのレポーターの標準化活動 | ||
- [テスト結果のStatusの標準化](https://github.com/js-reporters/js-reporters/issues/4 "test status") - Pass/Fail/Pending... | ||
- [テストのHook Eventの標準化](https://github.com/js-reporters/js-reporters/issues/1#issuecomment-54572441 "Standard Events/Hooks · Issue #1 · js-reporters/js-reporters") - SuiteStart/testEnd... | ||
- [レポーターAPIの標準化](https://github.com/js-reporters/js-reporters/issues/3 "Standard API · Issue #3 · js-reporters/js-reporters") - イベントベース? | ||
|
||
---- | ||
|
||
# まとめ | ||
|
||
- グローバル空間には`QUnit`のみ | ||
- `done`を使った非同期テストのサポート | ||
- `return promise`でのPromiseテストのサポート | ||
- `assert.expect`とPromiseテストの相性が良い | ||
- 2.0では互換レイヤーあり、2.1で完全移行 | ||
- 続きは [QUnit 2.x Upgrade Guide | QUnit](http://qunitjs.com/upgrade-guide-2.x/ "QUnit 2.x Upgrade Guide | QUnit") で | ||
|
||
---- | ||
|
||
# [azu/qunit-examples](https://github.com/azu/qunit-examples "azu/qunit-examples") |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# TC39 MTG Notes 第43回 報告会 | ||
|
||
----- | ||
|
||
# [4.3 Assignment to a const: static error?](https://github.com/tc39/tc39-notes/blob/master/es6/2014-11/nov-18.md#43-assignment-to-a-const-static-error "4.3 Assignment to a const: static error?") | ||
|
||
- ES6の`const`で定義した変数への代入はエラーに | ||
- 今まではstrict modeの時のみだった | ||
- strict mode / non-strict mode( sloppy mode)どちらもエラー | ||
- [Rationale for const not throwing in sloppy mode?](https://esdiscuss.org/topic/rationale-for-const-not-throwing-in-sloppy-mode "Rationale for const not throwing in sloppy mode?") | ||
|
||
```js | ||
const x = 42; | ||
x = 32;// Error!!! | ||
``` | ||
|
||
|
||
----- | ||
|
||
# [4.3 Assignment to a const: static error?](https://github.com/tc39/tc39-notes/blob/master/es6/2014-11/nov-18.md#43-assignment-to-a-const-static-error "4.3 Assignment to a const: static error?") | ||
|
||
- だがES5で`undefined`への代入等はnon-strict modeでは何も言わない | ||
- 代入しても無視されるだけでエラーが出ない | ||
- これは引き続きES6でも同じ仕様をが維持される | ||
|
||
----- | ||
|
||
```js | ||
"don't use strict"; | ||
// もちろんstrict modeならエラー | ||
Object.defineProperty(this, "globalReadOnly", { value: "readonly" }); | ||
|
||
var func = function f() { | ||
// silently skips assignment | ||
f = undefined; | ||
// silently skips assignment | ||
undefined = 42; | ||
Infinity = 0; | ||
}; | ||
func(); | ||
``` | ||
|
||
|
||
----- | ||
|
||
# [4.6 Zepto broken by new this.construct usage in some Array.prototype methods](https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-11/nov-18.md#46-zepto-broken-by-new-thisconstruct-usage-in-some-arrayprototype-methods "4.6 Zepto broken by new this.construct usage in some Array.prototype methods") | ||
|
||
- `new this.constructor()` がES5と互換なくなってたのは直す | ||
- ZeptoやPromiseのサブクラス的なもので見かける | ||
|
||
----- | ||
|
||
# [5.1 & 4.4 Array.prototype.contains and String.prototype.contains](https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-11/nov-18.md#51--44-arrayprototypecontains-and-stringprototypecontains "5.1 & 4.4 Array.prototype.contains and String.prototype.contains") | ||
|
||
- `Array.prototype.contains`はBreak the Web | ||
- `includes`に変更! | ||
- `String.prototype.contains` => `String.prototype.includes` | ||
- `Array.prototype.contains` => `Array.prototype.includes` | ||
|
||
----- | ||
|
||
# Array.prototype.containsの変更 | ||
|
||
- [ECMA, TC39 Meeting 2014-11のメモ | GH Issue Note](https://efcl.wordpress.com/2014/11/22/ecma-tc39-meeting-2014-11%e3%81%ae%e3%83%a1%e3%83%a2/ "ECMA, TC39 Meeting 2014-11のメモ | GH Issue Note") | ||
- ブラウザベンダーは大体当日にIssue立てて解決済み | ||
|
||
|
||
----- | ||
|
||
# [4.10 RegExp subclassing fixes](https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-11/nov-18.md#410-regexp-subclassing-fixes "4.10 RegExp subclassing fixes") | ||
|
||
- `RegExp.prototype.flags` というflagを取るメソッドを追加 | ||
- `/test/i.flags // i ` ? | ||
|
||
|
||
---- | ||
|
||
# [4.12 Should WeakMap/WeakSet have a .clear method? (MarkM)](https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-11/nov-19.md#412-should-weakmapweakset-have-a-clear-method-markm "4.12 Should WeakMap/WeakSet have a .clear method? (MarkM)") | ||
|
||
- WeakMap と WeakSet から `clear`メソッドが消えました | ||
- [Allen Wirfs-Brock on Twitter: "ES6 WeakMap and WeakSet 'clear' methods eliminated"](https://twitter.com/awbjs/status/535829756285964289 "Allen Wirfs-Brock on Twitter: "ES6 WeakMap and WeakSet 'clear' methods eliminated"") | ||
- 実装に考慮した感じっぽい | ||
|
||
----- | ||
# [Abstract references as a solution to LTR composition and private state](https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-11/nov-19.md#abstract-references-as-a-solution-to-ltr-composition-and-private-state "Abstract references as a solution to LTR composition and private state") | ||
|
||
-  [zenparsing/es-abstract-refs](https://github.com/zenparsing/es-abstract-refs "zenparsing/es-abstract-refs") | ||
- ビルドインオブジェクトをprivateに拡張するための抽象インターフェスの定義の提案 | ||
|
||
---- | ||
|
||
# [5.6 Object.observe: proposal to move to Stage 3.](https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-11/nov-20.md#56-objectobserve-proposal-to-move-to-stage-3 "5.6 Object.observe: proposal to move to Stage 3.") | ||
|
||
- :star: Object.observe がES7 Stage 3へ | ||
- 恐らくObject.observeが最初のStage 3 | ||
- 参照: [明日には使えなくなるES7トーク](http://azu.github.io/slide/es6talks/ "明日には使えなくなるES7トーク") | ||
|
||
----- | ||
|
||
# [5.4 I/O Streams as part of the ES standard library](https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-11/nov-20.md#54-io-streams-as-part-of-the-es-standard-library "5.4 I/O Streams as part of the ES standard library") | ||
|
||
- StreamをECMAScriptに入れるかどうかの話 | ||
- 入れたいとは思うが現状では難しい | ||
- I/Oとかそういうものの標準があるならばあるいは | ||
- 現在はWHATWGで管理してるので仕様団体的な議論 | ||
- 結局今は無理なので提案は撤回 | ||
|
||
---- | ||
# 成果 | ||
|
||
 | ||
|
||
- https://github.com/rwaldron/tc39-notes/pull/25 | ||
- https://github.com/rwaldron/tc39-notes/pull/24 | ||
|
||
|
||
---- | ||
|
||
# おわりに | ||
|
||
|
||
- [TC39 MTG Notes MTG | Doorkeeper](http://tc39-mtg.doorkeeper.jp/ "TC39 MTG Notes MTG | Doorkeeper") | ||
- 読む時毎回イベントを立てていく予定 | ||
- オンラインでTwitterに [#TC39MTG](https://twitter.com/search?f=realtime&q=%23TC39MTG&src=typd "#TC39MTG") とつぶやくだけ | ||
- 今回: [ECMA, TC39 Meeting Notes 第43回目を読む - TC39 MTG Notes MTG | Doorkeeper](http://tc39-mtg.doorkeeper.jp/events/18001 "ECMA, TC39 Meeting Notes 第43回目を読む - TC39 MTG Notes MTG | Doorkeeper") |
Binary file not shown.