test(startup): add startup test for missing DISCORD_TOKEN
This commit is contained in:
parent
74dfdbf667
commit
47de3823f3
10
package.json
10
package.json
@ -3,9 +3,10 @@
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node src/index.js",
|
||||
"test": "jest"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
@ -14,5 +15,8 @@
|
||||
"dotenv": "^16.5.0",
|
||||
"erela.js": "^2.4.0",
|
||||
"winston": "^3.17.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "^29.7.0"
|
||||
}
|
||||
}
|
||||
|
||||
13
tests/startup.test.js
Normal file
13
tests/startup.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
describe('Bot Startup', () => {
|
||||
test('exits with code 1 if DISCORD_TOKEN is missing', () => {
|
||||
// Clear DISCORD_TOKEN
|
||||
const env = { ...process.env };
|
||||
delete env.DISCORD_TOKEN;
|
||||
|
||||
const result = spawnSync('node', ['src/index.js'], { env, encoding: 'utf-8' });
|
||||
expect(result.status).toBe(1);
|
||||
expect(result.stderr || result.stdout).toMatch(/DISCORD_TOKEN is missing/);
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user