How can you create a new (xml) file in angular testing

1k Views Asked by At

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

There are 1 best solutions below

0
On

I missed the brackets.

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