`I.waitForFile` (FileSystem helper) fails if directory does not exist (yet)

オープン 初心者向け
#5,420 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
javascript, nodejs
領域
testing

調査の方向性

lib/helper/FileSystem.js の isFileExists から開始し、親ディレクトリが存在しない場合と、その timeout のクリーンアップを I.waitForFile がどのように処理するかを追跡してください。利用可能であれば、既存の FileSystem ヘルパーのカバレッジで動作を確認してください。完了条件は、ディレクトリが最初に存在しなくても待機で例外がスローされず、ファイルが出現した時点で引き続き検出できることです。

索引モデルが issue の本文から書いたものです。

説明

stale

I.waitForFile sometimes fails and throws weird exceptions if the directory containing the expected file does not exist yet.

Example (all output goes to ${codecept_dir}/output/):

  I.handleDownloads('downloads/example.txt');
  I.click('button.download');
  I.amInPath('output/downloads');
  I.waitForFile('example.txt', 5);

If the directory ${codecept_dir}/output/downloads does not exist yet (it will be created by the browser download at some point in time), the function I.waitForFile will throw an exception ReferenceError: Cannot access 'watcher' before initialization and the test will fail.

Root cause is in the function isFileExists of the FileSystem helper. The line const watcher = fs.watch(dir, (eventType, filename) => {... will throw if dir does not exist yet. This exception remains unhandled. Later, the timer for the 5sec timeout detection will try to close the uninitialized watcher, leading to the ReferenceError.

I will try to create a PR.

主要言語
JavaScript
スター
4.2k
フォーク
756
平均マージ
2日 9時間
マージ済み PR(30日)
16

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

codeceptjs/CodeceptJS のほかの issue

codeceptjs/CodeceptJS の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。