Running: cm/system/license.ts... (34 of 54)
Estimated: 31 seconds
System => License
1) "before each" hook for "should display correctly"
0 passing (57s)
1 failing
1) System => License "before each" hook for "should display correctly":
[cypress-file-upload error]: "encoding" is not valid.
Please look into docs to find supported "encoding" values
Because this error occurred during a 'before each' hook we are skipping the remaining tests in the current suite: 'System => License'
Code that used to work
Cypress.Commands.add('uploadLicense', { prevSubject: true }, (subject, mode: AnalyticsMode, name: string, validUntil: Date, evaluation: boolean) => {
if (!subject) {
throw new Error('uploadLicense must be chained off your upload target!');
}
return cy.exec(
`./node_modules/.bin/ts-node -T cypress/scripts/generate-license.ts "${mode}" "${name}" "${validUntil.toISOString()}" "${evaluation}"`,
{ env: Cypress.env() }
).then((result) => {
cy.wrap(result, { log: false }).its('code').should('equal', 0);
return cy.wrap(subject).upload(
[{
fileContent: btoa(result.stdout),
fileName: 'license.lic',
mimeType: 'text/plain',
encoding: 'utf-8'
}],
{
force: true,
subjectType: 'drag-n-drop'
});
});
});
That targets an ng2-upload target in Angular.
To accept utf-8 again
Cypress 3.4.0
Cypress File Upload 3.3.1
This comes down to:
https://docs.cypress.io/api/commands/readfile.html#Usage
Is the typing from cypress that contains more than:
https://github.com/abramenal/cypress-file-upload/blob/master/src/constants.js#L32
Hi @philjones88
Thanks for submitting the issue! You're right, new version introduced more agressive validation and it seems I've missed some values from original Cypress' list.
@all-contributors add @philjones88 for bug
@abramenal
I've put up a pull request to add @philjones88! :tada:
Now it's fixed in v3.3.2
Most helpful comment
Now it's fixed in v3.3.2