0

I am working on an unittest in a Angular(2) project. But I ran into an issue that I can not create a new File for my test.

In my test I have the following code:

const newfile = new Blob(['ANEWFILE001'], {
    type: 'application/xml',
    endings: 'native'
});

data = [
    {
        file: {
            file: new File(newfile, "FILENAME001.xml",)
        } as FileLoadBar
    }
];

file: new File(newfile, "FILENAME001.xml",)
newfile results in the following error:

Argument of type 'Blob' is not assignable to parameter of type '(string | ArrayBuffer | Blob | ArrayBufferView)[]'.
Property 'find' is missing in type 'Blob'.


How do I create a new File in an angular unitetest.
If there is any information needed for solving this issue please let me know.

1
  • Adding parenthesis is not the solution (blob has no compatible call signature error will occur) Commented Sep 1, 2017 at 13:04

1 Answer 1

0

I missed the brackets.

file: new File([newfile], "FILENAME001.xml",)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.