* Waits for the file to be present in the current directory. * * ```js * I.handleDownloads('downloads/largeFilesName.txt'); * I.click('Download large File'); * I.amInPath('output/downloads'); * I.waitForFile('largeFilesName.txt', 10); // wait 10 seconds for file * ``` * @para
(name, sec = 1)
| 99 | * @param {number} [sec=1] seconds to wait |
| 100 | */ |
| 101 | async waitForFile(name, sec = 1) { |
| 102 | if (sec === 0) assert.fail('Use `seeFile` instead of waiting 0 seconds!') |
| 103 | const waitTimeout = sec * 1000 |
| 104 | this.file = path.join(this.dir, name) |
| 105 | try { |
| 106 | this.debugSection('File', this.file) |
| 107 | } catch (e) { |
| 108 | // Fallback debug for ESM transition |
| 109 | console.log(`[File] ${this.file}`) |
| 110 | } |
| 111 | return isFileExists(this.file, waitTimeout).catch(() => { |
| 112 | throw new Error(`file (${name}) still not present in directory ${this.dir} after ${waitTimeout / 1000} sec`) |
| 113 | }) |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Checks that file with a name including given text exists in the current directory. |
no test coverage detected