LoginSignup
1
2

More than 5 years have passed since last update.

angularのテストで特定のテストだけを実行する

Last updated at Posted at 2018-01-09

it の代わりに fit もしくは describe の代わりに fdescribe を使うと、そのテストだけを実行してくれる

使い方

describe('Something', () => {
  beforeEach(() => {
    // ... preparation
  });

  it('should ...', async(() => {
    // ... test 1 logic here
  }));

  // ... more tests and/or nested `describe()` calls
});

itfit に変えるだけ。

describe('Something', () => {
  beforeEach(() => {
    // ... preparation
  });

  fit('should ...', async(() => {
    // ... test 1 logic here
  }));

  // ... more tests and/or nested `describe()` calls
});

例えば 31 個あるテストのうち一つを fit にすると、、、

Chrome 63.0.3239 (Mac OS X 10.11.6): Executed 31 of 31 SUCCESS (16.162 secs / 16.127 secs)

これが
こうなる↓

Chrome 63.0.3239 (Mac OS X 10.11.6): Executed 1 of 31 (skipped 30) SUCCESS (0.13 secs / 0.087 secs)

これは Angular のテストを作っていく上では必須の知識なので要チェック!

参考
https://github.com/angular/angular-cli/issues/3005

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2