Skip to content

Commit

Permalink
fix: proxy browser in build tests (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
adampash authored Jan 30, 2019
1 parent 0668f5d commit 244d17d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
23 changes: 10 additions & 13 deletions scripts/check-build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ let urls = [
},
{
url:
'https://www.cnn.com/2018/10/12/us/before-after-aerial-images-mexico-beach-devastation-trnd/index.html',
'https://www.cnn.com/2019/01/30/politics/trump-intel-chiefs-foreign-policy-iran-isis-north-korea/index.html',
title:
"Before and after images show there's nothing left in some parts of Mexico Beach",
'Trump chastises intel chiefs after they contradict him on Iran and claims of foreign policy success',
},
];

Expand All @@ -38,16 +38,13 @@ if (
typeof Mercury === 'undefined' ? require('../dist/mercury') : Mercury;

describe('Is Mercury build working', () => {
beforeAll(() => {
if (Merc.browser) {
const proxyUrl = 'http://localhost:3000/';
urls = urls.map(article => ({
title: article.title,
url: proxyUrl + article.url,
}));
}
});

if (Merc.browser) {
const proxyUrl = 'http://localhost:3000/';
urls = urls.map(article => ({
title: article.title,
url: proxyUrl + article.url,
}));
}
urls.map(article =>
it(`gets this title right ${article.title}`, done => {
Merc.parse(article.url)
Expand All @@ -60,7 +57,7 @@ if (
assert.equal(true, false);
done();
});
}, 10000)
}, 15000)
);
});
}
18 changes: 13 additions & 5 deletions scripts/proxy-browser-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const app = express();
var server;

const start = () => {
app.use('/', (req, res) => {
const url = req.url.slice(1);
app.use('/:url', (req, res) => {
const url = req.originalUrl.slice(1);

const options = {
url,
Expand All @@ -32,9 +32,17 @@ const stop = () => {
};

start();
require('child_process').execSync(
require('child_process').exec(
'node ./node_modules/karma/bin/karma start ./scripts/karma.conf.js' +
(process.env.CI ? ' --CI' : ''),
{ stdio: [0, 1, 2] }
{ stdio: [0, 1, 2] },
(err, stdout) => {
if (err) {
console.log('stdout', stdout);
process.exit(1);
} else {
console.log('stdout', stdout);
}
stop();
}
);
stop();

0 comments on commit 244d17d

Please sign in to comment.