Skip to content

Commit

Permalink
fix(test): master branch (#1272)
Browse files Browse the repository at this point in the history
  • Loading branch information
fivethreeo committed Apr 26, 2020
1 parent f650699 commit e9f71e7
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 51 deletions.
11 changes: 0 additions & 11 deletions test/fixtures/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,6 @@ module.exports = {
shell.cd(stagePath);
},

setupStageWithExample: (stageName, exampleName) => {
const stagePath = path.join(rootDir, stageName);
shell.mkdir(stagePath);
shell.exec(`cp -a ${rootDir}/examples/${exampleName}/. ${stagePath}/`);
shell.ln(
'-s',
path.join(rootDir, 'packages/razzle/node_modules'),
path.join(stagePath, 'node_modules')
);
shell.cd(stagePath);
},

teardownStage: stageName => {
shell.cd(rootDir);
Expand Down
55 changes: 31 additions & 24 deletions test/tests/razzle-start-spa.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,31 @@ const path = require("path");
const fs = require("fs");

shell.config.silent = true;
const stageName = "stage-start-spa";

describe("razzle start", () => {
describe("razzle basic example", () => {
const stageName = 'stage-start-spa';

describe('razzle start', () => {
describe('razzle basic example', () => {

beforeAll(() => {
util.teardownStage(stageName);
});

jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000; // eslint-disable-line no-undef

it("should start a dev server for spa mode", () => {
util.setupStageWithExample(stageName, "basic-spa");
it('should start a dev server for spa mode', () => {
util.setupStageWithExample(stageName, 'basic-spa');
let outputTest;
const run = new Promise((resolve) => {
const child = shell.exec("razzle start --type=spa --verbose", () => {
resolve(outputTest);
});
child.stdout.on("data", (data) => {
console.log(data);
if (data.includes("> SPA Started on port 3000")) {
shell.exec("sleep 5");
const run = new Promise(resolve => {
const child = shell.exec(
`${path.join('./node_modules/.bin/razzle')} start --type=spa`,
() => {
resolve(outputTest);
}
);
child.stdout.on('data', data => {
if (data.includes('> SPA Started on port 3000')) {
shell.exec('sleep 5');
const devServerOutput = shell.exec(
'curl -sb -o "" localhost:3000/static/js/bundle.js'
);
Expand All @@ -44,18 +48,20 @@ describe("razzle start", () => {

jasmine.DEFAULT_TIMEOUT_INTERVAL = 400000; // eslint-disable-line no-undef

it("should build and run in spa mode", () => {
util.setupStageWithExample(stageName, "basic-spa");
it('should build and run in spa mode', () => {
util.setupStageWithExample(stageName, 'basic-spa');
let outputTest;
shell.exec("razzle build --type=spa");
const run = new Promise((resolve) => {
const child = shell.exec("serve -s build/public", () => {
resolve(outputTest);
});
child.stdout.on("data", (data) => {
console.log(data);
if (data.includes("http://localhost:5000")) {
shell.exec("sleep 5");
shell.exec(`${path.join('./node_modules/.bin/razzle')} build --type=spa`);
const run = new Promise(resolve => {
const child = shell.exec(
`${path.join('./node_modules/.bin/serve')} -s ${path.join('build/public')}`,
() => {
resolve(outputTest);
}
);
child.stdout.on('data', data => {
if (data.includes('http://localhost:5000')) {
shell.exec('sleep 5');
// we use serve package and it will run in prot 5000
const output = shell.exec("curl -I localhost:5000");
outputTest = output.stdout.includes("200");
Expand All @@ -69,5 +75,6 @@ describe("razzle start", () => {
afterEach(() => {
util.teardownStage(stageName);
});

});
});
32 changes: 16 additions & 16 deletions test/tests/razzle-start.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ const path = require("path");

shell.config.silent = true;

const stageName = "stage-start";
const stageName = 'stage-start';

describe("razzle start", () => {
describe("razzle basic example", () => {
describe('razzle start', () => {
describe('razzle basic example', () => {
beforeAll(() => {
util.teardownStage(stageName);
});

jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000; // eslint-disable-line no-undef

it("should start a dev server", () => {
util.setupStageWithExample(stageName, "basic");
it('should start a dev server', () => {
util.setupStageWithExample(stageName, 'basic');
let outputTest;
const run = new Promise((resolve) => {
const child = shell.exec("razzle start --verbose", () => {
const run = new Promise(resolve => {
const child = shell.exec(`${path.join('./node_modules/.bin/razzle')} start`, () => {
resolve(outputTest);
});
child.stdout.on("data", (data) => {
Expand All @@ -43,11 +43,11 @@ describe("razzle start", () => {

jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000; // eslint-disable-line no-undef

it("should start a dev server on different port", () => {
util.setupStageWithExample(stageName, "with-custom-devserver-options");
it('should start a dev server on different port', () => {
util.setupStageWithExample(stageName, 'with-custom-devserver-options');
let outputTest;
const run = new Promise((resolve) => {
const child = shell.exec("razzle start --verbose", () => {
const run = new Promise(resolve => {
const child = shell.exec(`${path.join('./node_modules/.bin/razzle')} start`, () => {
resolve(outputTest);
});
child.stdout.on("data", (data) => {
Expand All @@ -68,12 +68,12 @@ describe("razzle start", () => {

jasmine.DEFAULT_TIMEOUT_INTERVAL = 400000; // eslint-disable-line no-undef

it("should build and run", () => {
util.setupStageWithExample(stageName, "basic");
it('should build and run', () => {
util.setupStageWithExample(stageName, 'basic');
let outputTest;
shell.exec("razzle build");
const run = new Promise((resolve) => {
const child = shell.exec(`node ${path.join("build/server.js")}`, () => {
shell.exec(`${path.join('./node_modules/.bin/razzle')} build`);
const run = new Promise(resolve => {
const child = shell.exec(`node ${path.join('build/server.js')}`, () => {
resolve(outputTest);
});
child.stdout.on("data", (data) => {
Expand Down

0 comments on commit e9f71e7

Please sign in to comment.