I'm trying to read env variables in an integration test. I've successfully read the .env file in my main.dart file using
await dotenv.load(fileName: ".env");, but attempting to use the testLoad() function in an integration test returns
OS Error: No such file or directory, errno = 2.
I've added the .env file path to assets section of the pubspec.yaml. The file is located at root level, so I'm attempting to read the file in the integration test using dotenv.testLoad(fileInput: File('.env').readAsStringSync());. I've also attempted moving the .env file to the root of my integration_test/ directory, which results in the same error mentioned above.
Is there anything I'm missing here? I don't get an error when reading the .env file in my integration test using
await dotenv.load(fileName: ".env");, but any attempt to log the variables within the file returns null.
I'm trying to read env variables in an integration test. I've successfully read the .env file in my main.dart file using
await dotenv.load(fileName: ".env");
, but attempting to use the testLoad() function in an integration test returnsOS Error: No such file or directory, errno = 2
.I've added the
.env
file path to assets section of the pubspec.yaml. The file is located at root level, so I'm attempting to read the file in the integration test usingdotenv.testLoad(fileInput: File('.env').readAsStringSync());
. I've also attempted moving the .env file to the root of myintegration_test/
directory, which results in the same error mentioned above.Is there anything I'm missing here? I don't get an error when reading the .env file in my integration test using
await dotenv.load(fileName: ".env");
, but any attempt to log the variables within the file returnsnull
.Thanks in advance.