From f50c88515e4a15663344c54958645bd8dabe4c82 Mon Sep 17 00:00:00 2001 From: aki Date: Wed, 23 Apr 2025 22:09:00 +0800 Subject: [PATCH] test(scripts): add npm start script test --- tests/start-script.test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/start-script.test.js diff --git a/tests/start-script.test.js b/tests/start-script.test.js new file mode 100644 index 0000000..e40bc1f --- /dev/null +++ b/tests/start-script.test.js @@ -0,0 +1,10 @@ +const { spawnSync } = require('child_process'); + +describe('NPM Start Script', () => { + test('npm start exits without error when DISCORD_TOKEN is provided', () => { + const env = { ...process.env, DISCORD_TOKEN: 'dummy-token', CLIENT_ID: '123', LAVALINK_HOST: 'localhost', LAVALINK_PORT: '2333', LAVALINK_PASSWORD: 'pass' }; + const result = spawnSync('pnpm', ['start'], { env, encoding: 'utf-8' }); + // The script starts the bot; if it reaches login attempt, exit code is 0 + expect(result.status).toBe(0); + }); +});