Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Cannot set property name of which has only getter. Where does it come from? #349

Open
VRa3 opened this issue Nov 28, 2021 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@VRa3
Copy link

VRa3 commented Nov 28, 2021

Current behavior:

I wrote a function that allows me to upload files by request when needed (e.g. creating default project without UI clicking). Here's code for it :

cy.wait(1000)
    .window()
    .then((win) => {
        const requestObject = {
            method: 'POST',
            url: `${(win as any).remote_service_base_url}/my-endpoint`,
            headers: {
                authorization: 'bearer ' + (win as any).abp.auth.getToken(),
                'content-type': 'multipart/form-data',
            },
        };

        cy.fixture(FilesPage.singleFile, 'binary')
            .then((file) => Cypress.Blob.binaryStringToBlob(file))
            .then((blob) => {
                const formData = new FormData();
                formData.append('projectId', projectId);
                formData.append('comment', '');
                formData.append(FilesPage.firstFileName, blob, FilesPage.firstFileName);

                cy.request({ ...requestObject, body: formData }).then((response) => {
                    expect(response.status).to.eq(200);
                    cy.wait(500);

                    if (amountOfFiles === 2) {
                        cy.fixture(`${FilesPage.filesPath}/${FilesPage.secondFileName}`, 'binary')
                            .then((file) => Cypress.Blob.binaryStringToBlob(file))
                            .then((blob) => {
                                const formData = new FormData();
                                formData.append('projectId', projectId);
                                formData.append('comment', '');
                                formData.append(FilesPage.secondFileName, blob, FilesPage.secondFileName);

                                cy.request({ ...requestObject, body: formData }).then((response) => {
                                    expect(response.status).to.eq(200);
                                    cy.wait(5000);
                                });
                            });
                    }
                });
            });
    });

And this works just fine, it does its job.

However, in next test suite I use cypress-file-upload package and method attachFile

cy.log('before attachFile');
cy.get('p-fileupload input[type="file"]').wait(1000).attachFile({
    filePath: filePath,
    encoding: 'base64',
});
cy.log('after attachFile');

to upload files using the UI and I get this error. You can see that after using attachFile method the following cy.log is not invoked:

Cannot set property name of ? which has only getter

The stack trace for this error is here, I couldn't find hints there:

Stack trace

What I could notice, is that if I skip the function that uploads files by request the attachFile method works as expected.

Desired behavior:

A desired behavior here would be working functionality of attachFile method no matter if upload by request is used or not.

Versions

cypress: 8.3.0
cypress-file-upload: 5.0.8
operating system: windows 10 20H2
browser: Chrome 96

I've seen topic about this error message on stackoverflow, and tried solution, but this doesn't solve the problem.

@VRa3 VRa3 added the bug Something isn't working label Nov 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants