Skip to main content
Version: 2x

@qavajs/steps-files

Step library to work with file system

Installation

npm install @qavajs/steps-files

Configuration

export default {
require: [
'node_modules/@qavajs/steps-files/index.js'
],
// add fileTimeout property in case you need to customize built-in interval and timeout
fileTimeout: {
interval: 1000,
timeout: 1000
}
}


Wait Steps


I expect file matching {string} regexp appears in {string}

Verify that file matching regexp appears in directory

paramtypedescriptionexample
filestringfile name regex to waitf.+.txt
dirstringdirectory path to wait./yourFolder
When I expect file matching 'f.+\.txt' regexp appears in './test-e2e/folder'
When I expect file matching '$fileRegexp' regexp appears in '$folder'

I expect {string} file appears

Verify that file appears in provided location

paramtypedescriptionexample
filestringfile path to wait./yourFolder/file.txt
When I expect './test-e2e/folder/file.txt' file appears
When I expect '$filePath' file appears

Validation Steps


I expect {string} text file content {validation} {string}

Verify that text file content satisfy validation

paramtypedescriptionexample
filestringfile path./yourFolder/file.txt
validationTypestringfile pathto be equal, to contain
expectedValuestringexpected valuetext, $value
When I expect './folder/file.txt' text file content to be equal 'file content'
When I expect '$filePath' text file content to contain '$content'

Memory Steps


I save {string} file content as {string}

Save file content to memory as buffer

paramtypedescriptionexample
filestringfile path./yourFolder/file.jpeg
memoryKeystringmemory keyfileContent, value
When I save './folder/file.txt' file content as 'fileContent'
When I save '$filePath' file content as 'fileContent'

I save {string} text file content as {string}

Save file content to memory as text (utf-8)

paramtypedescriptionexample
filestringfile path./yourFolder/file.txt
memoryKeystringmemory keytextContent, value
When I save './folder/file.txt' text file content as 'fileContent'
When I save '$filePath' text file as 'fileContent'

I save {string} Excel file content as {string}

Save file content to memory as Excel object (https://www.npmjs.com/package/xlsx)

paramtypedescriptionexample
filestringfile path./yourFolder/file.xlsx
memoryKeystringmemory keyexcelContent, value
When I save './folder/file.txt' Excel file content as 'fileContent'
When I save '$filePath' Excel file as 'fileContent'
# if you use @qavajs/steps-memory package
Then I expect '$excelFile.Sheets.SheetName.A1.v' to be equal 'expectedValueOfCell'

I save {string} pdf file content as {string}

Save file content to memory as pdf object with following properties:

propertytypedescription
textMultiLinestringtext of pdf in multiline format
textSingleLinestringtext of pdf in single-line format
metadataObjectpdf metadata
paramtypedescriptionexample
filestringfile path./yourFolder/file.txt
memoryKeystringmemory keytextContent, value
When I save './folder/file.pdf' pdf file content as 'pdfContent'
When I save '$filePath' pdf file content as 'pdfContent'
# if you use @qavajs/steps-memory package
Then I expect '$pdfContent.textMultiLine' to be equal 'expectedPdfContent'
Then I expect '$pdfContent.textSingleLine' to be equal 'expectedPdfContent'

I save {string} Word file content as {string}

Save file content to memory as word object with following properties:

propertytypedescription
textMultiLinestringtext of word document in multiline format
textSingleLinestringtext of word document in single-line format
paramtypedescriptionexample
filestringfile path or buffer./yourFolder/file.docx
memoryKeystringmemory keywordContent, value
When I save './folder/file.docx' Word file content as 'wordContent'
When I save '$filePath' Word file content as 'wordContent'
When I save '$fileBuffer' Word file content as 'wordContent'
# if you use @qavajs/steps-memory package
Then I expect '$wordContent.textMultiLine' to be equal 'expectedPdfContent'
Then I expect '$wordContent.textSingleLine' to be equal 'expectedPdfContent'

I save {string} csv file content as {string}

Save file content to memory as csv object. First row will is considered as header.

paramtypedescriptionexample
filestringfile path or buffer./yourFolder/file.csv
memoryKeystringmemory keycsvContent, value
When I save './folder/file.csv' csv file content as 'csvContent'
When I save '$filePath' csv file as 'csvContent'
# if you use @qavajs/steps-memory package
Then I expect '$csvContent[0].columnName' to be equal 'expectedValue'