jferrettiboke
03/23/2018, 12:36 PMprisma reset --env-file ./.env --force
but Prisma returns an error saying "Error: Couldn’t find prisma.yml
file. Are you in the right directory?". When my script is executed, it is on the root path of the project but I am executing tests under /tests
. Any idea how to solve this? I have trying with many workarounds but nothing seems to work.picosam
03/23/2018, 1:05 PMjferrettiboke
03/23/2018, 1:08 PM#!/bin/bash
prisma reset --env-file ./.env --force
And everything is fine if I run it from the root path: bash script.sh
.
My issue comes when I execute this script from my test file located on /tests/auth.test.js
.picosam
03/23/2018, 1:11 PMpicosam
03/23/2018, 1:11 PMglobalSetup
or testEnvironment
?picosam
03/23/2018, 1:13 PMprisma reset
is to restore the state of the data to what was previously, for instance, `seed`ed, no?jferrettiboke
03/23/2018, 1:13 PMglobalSetup
or testEnvironment
. I really appreciate if you could share with me some examples.jferrettiboke
03/23/2018, 1:13 PMpicosam
03/23/2018, 1:14 PMpicosam
03/23/2018, 1:14 PMyarn test
?jferrettiboke
03/23/2018, 1:14 PMyarn test
and yarn test --watch
.picosam
03/23/2018, 1:16 PMprisma.yml
error” you stated.jferrettiboke
03/23/2018, 1:19 PMnilan
03/23/2018, 1:20 PMprisma
checks .graphqlconfig.yml
to find the prisma.yml
file. try to change the working directory to the directory where .graphqlconfig.yml
is located 🙂jferrettiboke
03/23/2018, 1:22 PMnilan
03/23/2018, 1:22 PMpicosam
03/23/2018, 1:25 PMjferrettiboke
03/23/2018, 1:26 PMgraphqlconfig.yml
. Should I still need to change the working directory?jferrettiboke
03/23/2018, 1:26 PMpicosam
03/23/2018, 1:26 PMjferrettiboke
03/23/2018, 1:42 PM+ /
+ /tests
- auth.test.js
- graphqlconfig.yml
- script.sh
graphqlconfig.yml
projects:
# ...
database:
schemaPath: src/generated/prisma.graphql
includes: ["database/seed.graphql"]
extensions:
prisma: database/prisma.yml
script.sh
#!/bin/bash
# Reset current stage for current cluster
prisma reset --env-file ./.env --force
auth.test.js
//...
beforeAll(done => {
shell.exec("bash script.sh", function(code, stdout, stderr) {
console.log("Exit code:", code);
console.log("Program output:", stdout);
console.log("Program stderr:", stderr);
done();
});
});
//...
- I am on /
- I execute yarn test
- I get "Couldn’t find prisma.yml
file. Are you in the right directory?"
Any specific example to help me with this? I don't know exactly what's wrong here.picosam
03/23/2018, 1:49 PMshell.exec
actually allows you to determine what working directory you want to execute from. Can you try shell.exec("bash script.sh, , {cwd: PUT_PATH_TO_GRAPHQLCONFIG.YML_HERE}, ...
jferrettiboke
03/23/2018, 1:59 PMshell.exec("bash script.sh", { cwd: path.resolve(__dirname, "..") }, ...
.jferrettiboke
03/23/2018, 1:59 PMprisma.yml
.picosam
03/23/2018, 2:02 PMconsole.log(path.resolve(__dirname, "..")
do you get the correct path?jferrettiboke
03/23/2018, 2:03 PMjferrettiboke
03/23/2018, 2:08 PMscript.js
with just this and everything works!
const shell = require("shelljs");
const path = require("path");
shell.exec("bash script.sh", { cwd: path.resolve(__dirname, "..") }, function(
code,
stdout,
stderr
) {
console.log("Exit code:", code);
console.log("Program output:", stdout);
console.log("Program stderr:", stderr);
});
So, is this a Jest issue? :Spicosam
03/23/2018, 2:12 PMjferrettiboke
03/23/2018, 2:14 PMchild_process
and still the same but it works on script.js
without Jest. I think it is something related with Jest. Pretty weird...jferrettiboke
03/23/2018, 2:14 PM