main.js 674 B

12345678910111213141516171819202122232425262728293031
  1. const { app, net, session } = require('electron');
  2. if (process.env.TEST_DUMP_FILE) {
  3. app.commandLine.appendSwitch('log-net-log', process.env.TEST_DUMP_FILE);
  4. }
  5. function request () {
  6. return new Promise((resolve) => {
  7. const req = net.request(process.env.TEST_REQUEST_URL);
  8. req.on('response', () => {
  9. resolve();
  10. });
  11. req.end();
  12. });
  13. }
  14. app.whenReady().then(async () => {
  15. const netLog = session.defaultSession.netLog;
  16. if (process.env.TEST_DUMP_FILE_DYNAMIC) {
  17. await netLog.startLogging(process.env.TEST_DUMP_FILE_DYNAMIC);
  18. }
  19. await request();
  20. if (process.env.TEST_MANUAL_STOP) {
  21. await netLog.stopLogging();
  22. }
  23. app.quit();
  24. });