dimanche 6 octobre 2019

Why expo-FileSystem dose not work in Jest?

I am trying to write some tests for my little project. We used expo-file-system to allow us access IOS internal storage. And here is my test for our saving function.

import SaveData from "../app/resources/SaveData/SaveData"
import * as FileSystem from 'expo-file-system';

var promiseHolder = 0;

describe('\nsaveNewFile() is tested.\n', ()=>{
it("A file is going to be created.",async ()=>{
    await FileSystem.writeAsStringAsync("cao","test.txt");
    promiseHolder = await FileSystem.getInfoAsync("test.txt");
    gan = await FileSystem.readAsStringAsync("test.txt");
    console.log(promiseHolder)
    console.log(gan)
  });
});

And here is the output. Command line output

It looks like FileSystem.documentDirectory does not work in test, but our app works well. What should I do?

Aucun commentaire:

Enregistrer un commentaire