Skip to content

Commit

Permalink
Symlink root dir for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timfish committed Aug 12, 2021
1 parent a26a5d1 commit 15d80ac
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 23 deletions.
11 changes: 10 additions & 1 deletion test/e2e/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import { expect, should, use } from 'chai';
import * as chaiAsPromised from 'chai-as-promised';
import { spawnSync, SpawnSyncOptionsWithBufferEncoding } from 'child_process';
import { join } from 'path';
import { dirname, join } from 'path';
import { inspect } from 'util';
import { symlinkSync, mkdirSync, existsSync } from 'fs';

import { TestContext } from './context';
import { downloadElectron } from './download';
import { TestServer, TestServerEvent } from './server';
import { getLastFrame } from './utils';

// Symlink the root directory into a fake node_modules directory so all the tests
// can simply require('@sentry/electron;)
const symLinkDst = join(__dirname, '../node_modules/@sentry/electron');
mkdirSync(dirname(symLinkDst), { recursive: true });
if (!existsSync(symLinkDst)) {
symlinkSync(join(__dirname, '../../'), symLinkDst);
}

const SENTRY_KEY = '37f8a2ee37c0409d8970bc7559c7c7e4';

should();
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/test-apps/isolated-app/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ const path = require('path');
const url = require('url');

const { app, BrowserWindow } = require('electron');

const { init } = require('../../../../../');
const { init } = require('@sentry/electron');

init({
dsn: 'http://37f8a2ee37c0409d8970bc7559c7c7e4@localhost:8123/277345',
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/test-apps/isolated-app/src/renderer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { init, configureScope } = require('../../../../../');
const { init, configureScope } = require('@sentry/electron');

init({
debug: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { configureScope, setUser } = require('../../../../../');
const { configureScope, setUser } = require('@sentry/electron');
if (process.type === 'browser') {
configureScope((scope) => {
scope.setExtra('a', 2);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { configureScope } = require('../../../../../');
const { configureScope } = require('@sentry/electron');
if (process.type === 'browser') {
configureScope((scope) => {
scope.setExtra('a', 2);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { configureScope } = require('../../../../../');
const { configureScope } = require('@sentry/electron');
if (process.type === 'renderer') {
configureScope((scope) => {
scope.setExtra('a', 2);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { init } = require('../../../../../');
const { init } = require('@sentry/electron');

init({
dsn: process.env.DSN,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if (process.type === 'browser') {
const { init } = require('../../../../../main');
const { init } = require('@sentry/electron/main');

init({
dsn: process.env.DSN,
Expand All @@ -11,7 +11,7 @@ if (process.type === 'browser') {
},
});
} else {
const { init } = require('../../../../../renderer');
const { init } = require('@sentry/electron/renderer');
const { Integrations } = require('@sentry/tracing');

init({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if (process.type === 'browser') {
const { init } = require('../../../../../main');
const { init } = require('@sentry/electron/main');

init({
dsn: process.env.DSN,
Expand All @@ -10,7 +10,7 @@ if (process.type === 'browser') {
},
});
} else {
const { init, Integrations } = require('../../../../../renderer');
const { init, Integrations } = require('@sentry/electron/renderer');
const { defaultIntegrations } = require('@sentry/browser');

init({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { init } = require('../../../../../');
const { init } = require('@sentry/electron');

init({
dsn: process.env.DSN,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { init } = require('../../../../../');
const { init } = require('@sentry/electron');

init({
dsn: process.env.DSN,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { init, configureScope, Integrations } = require('../../../../../');
const { init, configureScope, Integrations } = require('@sentry/electron');

init({
dsn: process.env.DSN,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { init, configureScope, Integrations } = require('../../../../../');
const { init, configureScope, Integrations } = require('@sentry/electron');

init({
dsn: process.env.DSN,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// eslint-disable-next-line no-unused-vars
const { app } = require('electron');

const { init } = require('../../../../../');
const { init } = require('@sentry/electron');

init({
dsn: process.env.DSN,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { init, configureScope } = require('../../../../../');
const { init, configureScope } = require('@sentry/electron');

init({
dsn: process.env.DSN,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { app } = require('electron');

const { init } = require('../../../../../');
const { init } = require('@sentry/electron');

init({
dsn: process.env.DSN,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/test-apps/node-integration/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require('./load-sentry');

app.on('ready', () => {
const window = new BrowserWindow({
show: !!process.env.DEBUG,
show: false,
webPreferences: { nodeIntegration: true, contextIsolation: false },
});

Expand Down

0 comments on commit 15d80ac

Please sign in to comment.