Is there a way to write my own custom assertion which can check if the file exists or not ? I have tried every implementations as the docs said but it seems not working !
Here is my code:
const fs = require('fs');
exports.assertion = function (path) {
this.message = 'Testing if file exists';
this.expected = true;
this.pass = (value) => {
return value === this.expected;
};
this.value = (result) => {
return result;
};
this.command = (callback) => {
return this.api.execute(function (filePath) {
try {
fs.existsSync(filePath);
return true;
} catch (err) {
return false;
}
}, [path],
function (result) {
callback(result.value);
});
};
};
browser
.click('#export-postgres-btn')
.assert.checkFileExists(`~/Downloads/${diagramName}.sql`);
The result is always false even when the file does exist !
Aucun commentaire:
Enregistrer un commentaire