Skip to content

Commit 2eceacb

Browse files
committed
chore(tests): fixed test setup
1 parent c7417aa commit 2eceacb

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

playground/config/env/test/database.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
import path from 'path';
2+
13
export default ({ env }) => ({
24
connection: {
35
client: "sqlite",
46
connection: {
5-
filename: env("DATABASE_TEST_FILENAME", ".tmp/test.db"),
7+
filename: path.join(
8+
__dirname,
9+
'..',
10+
// We need to go back once more to get out of the dist folder
11+
'..',
12+
env("DATABASE_TEST_FILENAME", ".tmp/test.db")),
613
},
714
useNullAsDefault: true,
815
debug: false,

playground/src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = {
88
*
99
* This gives you an opportunity to extend code.
1010
*/
11-
register(/*{ strapi }*/) {},
11+
register(/*{ strapi }*/) { },
1212

1313
/**
1414
* An asynchronous bootstrap function that runs before
@@ -64,7 +64,7 @@ module.exports = {
6464
.updateRole(publicRole.id, publicRole);
6565
}
6666

67-
strapi.entityService.create('plugin::webtools.url-pattern', {
67+
await strapi.entityService.create('plugin::webtools.url-pattern', {
6868
data: {
6969
pattern: '/page/[title]',
7070
label: 'Test API pattern',
@@ -74,7 +74,7 @@ module.exports = {
7474
}
7575
});
7676

77-
strapi.entityService.create('plugin::webtools.url-pattern', {
77+
await strapi.entityService.create('plugin::webtools.url-pattern', {
7878
data: {
7979
pattern: '/category/[title]',
8080
label: 'Category API pattern',
@@ -84,7 +84,7 @@ module.exports = {
8484
}
8585
});
8686

87-
strapi.entityService.create('plugin::webtools.url-pattern', {
87+
await strapi.entityService.create('plugin::webtools.url-pattern', {
8888
data: {
8989
pattern: '/private-category/[title]',
9090
label: 'Private category API pattern',
@@ -114,7 +114,7 @@ module.exports = {
114114
}
115115
});
116116

117-
strapi.entityService.create('api::test.test', {
117+
await strapi.entityService.create('api::test.test', {
118118
data: {
119119
title: 'Published test page',
120120
publishedAt: new Date(),
@@ -123,7 +123,7 @@ module.exports = {
123123
}
124124
});
125125

126-
strapi.entityService.create('api::test.test', {
126+
await strapi.entityService.create('api::test.test', {
127127
data: {
128128
title: 'Unpublished test page',
129129
category: publishedCategory.id,

playground/tests/helpers.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,17 @@ async function setupStrapi() {
5959
*/
6060
async function stopStrapi() {
6161
if (instance) {
62-
62+
await instance.server.httpServer.close();
63+
await instance.db.connection.destroy();
6364
instance.destroy();
64-
6565
const tmpDbFile = strapi.config.get(
6666
"database.connection.connection.filename"
6767
);
6868

6969
if (fs.existsSync(tmpDbFile)) {
7070
fs.unlinkSync(tmpDbFile);
7171
}
72+
7273
}
7374
return instance;
7475
}

0 commit comments

Comments
 (0)