function expectBytesAreFormat (bytes, fileType) {
  switch (fileType) {
    // see https://en.wikipedia.org/wiki/List_of_file_signatures
    case 'png':
      return expect(new Uint8Array(bytes).subarray(0, 8)).toEqual(Uint8Array.from([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]))
    case 'pdf':
      return expect(new Uint8Array(bytes).subarray(0, 5)).toEqual(Uint8Array.from(Buffer.from('%PDF-', 'utf8')))
    case 'svg':
      return expect(new Uint8Array(bytes).subarray(0, 4)).toEqual(Uint8Array.from(Buffer.from('<svg', 'utf8')))
    default:
      throw new Error('Unsupported filetype')
  }
}
Confirms the filetype of the given bytes

@param {Uint8Array} bytes - The bytes of the file to check
@param {"png"|"pdf"|"svg"} fileType - The filetype to check for