handsome-cartoon-58565
01/13/2022, 10:28 AMcy.exec
bumpy-yacht-37274
01/13/2022, 10:30 AMhandsome-cartoon-58565
01/13/2022, 10:33 AMcy.exec
? i don't see it in this snippethandsome-cartoon-58565
01/13/2022, 10:34 AMdocsUrl
handsome-cartoon-58565
01/13/2022, 10:34 AMhandsome-cartoon-58565
01/13/2022, 10:36 AMbeforeEach
hook of 'Dashborad' test suite, as error saysbumpy-yacht-37274
01/13/2022, 10:42 AMbumpy-yacht-37274
01/13/2022, 10:42 AMbeforeEach(() => {
cy.exec("npm run db:e2e:refresh", { timeout: 20000 });
cy.clock(NOW);
});
bumpy-yacht-37274
01/13/2022, 10:42 AMbumpy-yacht-37274
01/13/2022, 10:43 AMbumpy-yacht-37274
01/13/2022, 10:43 AMcy.request
, and cy.visit
bumpy-yacht-37274
01/13/2022, 10:44 AMdocsUrl
is sth that cypress code tries to assignhandsome-cartoon-58565
01/13/2022, 11:12 AMnpm run db:e2e:refresh
script looks like?
have you tried clearing (remove it's code and leave a simple console.log
to know the script is ran) the refresh-database.ts
script to see if it's "guilty" in any way?bumpy-yacht-37274
01/13/2022, 11:14 AMcy.exec
not always fail. It won't fail when I'm running it.only
so it's run. Maybe on subsequent runs it fails. It looks like: "db:e2e:refresh": "npm run typeorm-env apps/smartfm-e2e/src/scripts/refresh-database.ts",
bumpy-yacht-37274
01/13/2022, 11:15 AM"typeorm-env": "ts-node -P apps/api/tsconfig.typeorm.json",
bumpy-yacht-37274
01/13/2022, 11:15 AMhandsome-cartoon-58565
01/13/2022, 11:20 AMbumpy-yacht-37274
01/13/2022, 12:17 PMbumpy-yacht-37274
01/13/2022, 12:22 PMbumpy-yacht-37274
01/13/2022, 12:23 PMbumpy-yacht-37274
01/13/2022, 12:29 PMtry {
refreshDatabase();
console.log("refresh database");
} catch (e) {
console.error(e);
}
but the error with docsUrl
still occurs, maybe sth that happens earlierbumpy-yacht-37274
01/13/2022, 12:32 PM// eslint-disable-next-line @typescript-eslint/no-var-requires
import * as de from "dotenv";
import { Client } from "pg";
async function refreshDatabase(): Promise<void> {
de.config();
const env = process.env;
const client = new Client({
user: env.TYPEORM_USERNAME,
host: env.TYPEORM_HOST,
database: "smartom",
password: env.TYPEORM_PASSWORD,
port: env.TYPEORM_PORT,
});
client.connect();
await client.query(`DROP DATABASE IF EXISTS smartom_e2e WITH (FORCE)`);
await client.query(`CREATE DATABASE smartom_e2e TEMPLATE smartom_e2e_tpl`);
await client.end();
}
try {
refreshDatabase();
console.log("refresh database");
} catch (e) {
console.error(e);
}
bumpy-yacht-37274
01/13/2022, 12:32 PMdocsUrl
error still happensbumpy-yacht-37274
01/13/2022, 12:32 PMhandsome-cartoon-58565
01/13/2022, 12:53 PMrefreshDatabase
to do all it's async work, do you?
https://gist.github.com/memee/56fc0227ea4802f1fd026bfcb4445182#file-refresh-database-ts-L21
try this
js
try {
await refreshDatabase();
console.log("refresh database");
} catch (e) {
console.error(e);
}
handsome-cartoon-58565
01/13/2022, 12:54 PMjs
refreshDatabase().catch(console.error)
which should log any caught errorbumpy-yacht-37274
01/13/2022, 8:20 PMbumpy-yacht-37274
01/13/2022, 8:21 PMhandsome-cartoon-58565
01/13/2022, 8:39 PMrefreshDatabase()
?bumpy-yacht-37274
01/14/2022, 5:26 AMrefresh-database.ts
looks like: https://gist.github.com/memee/d264d606d3f61d599aa63a2e0dbdecbdbumpy-yacht-37274
01/14/2022, 5:26 AMdocsUrl
error after few tests passedbumpy-yacht-37274
01/14/2022, 5:29 AMbumpy-yacht-37274
01/14/2022, 5:30 AMbumpy-yacht-37274
01/14/2022, 5:30 AMerror?.docsUrl
bumpy-yacht-37274
01/14/2022, 5:31 AMbumpy-yacht-37274
01/14/2022, 5:32 AM