Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a50cd7d
:arrow_up: Webpack v5 and fix main deprecated
GuiDevloper Dec 21, 2021
951db8c
:arrow_up: :rotating_light: Upgrade deprecated webpack plugins
GuiDevloper Dec 28, 2021
bda72bf
:triangular_flag_on_post: :bug: Improve and make cache optional on build
GuiDevloper Dec 28, 2021
754c60c
Merge branch 'next' into wp-5-upgrade
GuiDevloper Dec 28, 2021
e72fea2
Merge branch 'next' into wp-5-upgrade
GuiDevloper Jan 2, 2022
5938fec
Merge remote-tracking branch 'upstream/master' into wp-5-upgrade
GuiDevloper Jan 17, 2022
f8270fb
:bug: Support webpack 5 error handling
GuiDevloper Jan 17, 2022
2ac50c3
:heavy_plus_sign: Unify tests processes with jest-puppeteer
GuiDevloper Jan 20, 2022
d30a389
:green_heart: Add Puppeteer CI config & teardown
GuiDevloper Jan 20, 2022
cc9684f
:green_heart: Add Github Action to test PRs
GuiDevloper Jan 20, 2022
0d77ac9
:green_heart: Remove the need for a jest-environment
GuiDevloper Jan 20, 2022
5f94cc2
:white_check_mark: Remove tests boilerplate & support CI pt1
GuiDevloper Jan 20, 2022
94e3852
:white_check_mark: Remove tests boilerplate & support CI pt2
GuiDevloper Jan 20, 2022
bad367c
:white_check_mark: Remove tests boilerplate & support CI pt3
GuiDevloper Jan 20, 2022
f4e4ef6
:white_check_mark: Replace tests use of `browser` for `context`
GuiDevloper Jan 23, 2022
b199bfd
:white_check_mark: Remove use of `Boolean` from tests
GuiDevloper Jan 24, 2022
0b188ee
:white_check_mark: Remove local `newPage` use from every test
GuiDevloper Jan 25, 2022
493d70c
Merge remote-tracking branch 'upstream/next' into next
GuiDevloper Jan 29, 2022
d26e75d
Merge branch 'next' into wp-5-upgrade
GuiDevloper Jan 29, 2022
e7c9378
Merge pull request #155 from GuiDevloper/tests-ci
Mortaro Jan 30, 2022
6be3da4
Merge pull request #144 from GuiDevloper/wp-5-upgrade
Mortaro Jan 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Nullstack Tests

on:
pull_request:
branches: [ master, next ]

jobs:
build:

runs-on: ubuntu-latest
container: lironavon/docker-puppeteer-container:14.16.0
env:
CI: true

strategy:
matrix:
node-version: [12.20.0, 14.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
# cache the dependencies from any node_modules directory
- name: Cache dependencies
uses: actions/cache@v2
with:
path: |
**/node_modules
**/package-lock.json
key: node_modules-${{ matrix.node-version }}-${{ hashFiles('**/package.json') }}

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Install and link main deps
run: |
npm install
npm link

- name: Install deps at tests folder
working-directory: ./tests
run: |
npm link nullstack
npm install

- name: Run tests
working-directory: ./tests
run: npm test
10 changes: 8 additions & 2 deletions builders/spa.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = async function spa(folder = 'spa') {
module.exports = async function spa({ output, cache }) {
const folder = output || 'spa';
process.env.NULLSTACK_ENVIRONMENT_MODE = 'spa';

const dir = process.cwd();
Expand Down Expand Up @@ -32,5 +33,10 @@ module.exports = async function spa(folder = 'spa') {
console.log()

console.log('\x1b[36m%s\x1b[0m', ` ✅️ ${application.project.name} is ready at ${folder}\n`);
process.exit()

if (cache) {
console.log('Storing cache...');
} else {
process.exit();
}
}
10 changes: 8 additions & 2 deletions builders/ssg.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = async function ssg(folder = 'ssg') {
module.exports = async function ssg({ output, cache }) {
const folder = output || 'ssg';
process.env.NULLSTACK_ENVIRONMENT_MODE = 'ssg';

const dir = process.cwd();
Expand Down Expand Up @@ -101,5 +102,10 @@ module.exports = async function ssg(folder = 'ssg') {
console.log()

console.log('\x1b[36m%s\x1b[0m', ` ✅️ ${application.project.name} is ready at ${folder}\n`);
process.exit()

if (cache) {
console.log('Storing cache...');
} else {
process.exit();
}
}
8 changes: 6 additions & 2 deletions builders/ssr.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
module.exports = async function ssr() {
module.exports = async function ssr({ cache }) {
const dir = process.cwd();
const application = require(`${dir}/.production/server`).default;

console.log('\x1b[36m%s\x1b[0m', `\n ✅️ ${application.project.name} is ready for production\n`);

process.exit()
if (cache) {
console.log('Storing cache...');
} else {
process.exit();
}
}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@
"fs-extra": "^10.0.0",
"glob": "^7.1.7",
"ignore-loader": "^0.1.2",
"mini-css-extract-plugin": "^0.9.0",
"mini-css-extract-plugin": "^2.4.5",
"node-fetch": "3.0.0",
"nodemon-webpack-plugin": "^4.3.1",
"purgecss-webpack-plugin": "^2.2.0",
"purgecss-webpack-plugin": "^4.1.3",
"raw-loader": "^4.0.2",
"sass": "^1.32.11",
"sass-loader": "^8.0.2",
"string-replace-loader": "^2.2.0",
"terser-webpack-plugin": "^2.3.5",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11",
"string-replace-loader": "^3.1.0",
"terser-webpack-plugin": "^5.3.0",
"webpack": "^5.65.0",
"webpack-cli": "^4.9.1",
"webpack-livereload-plugin": "^2.3.0",
"ws": "^7.4.4"
}
Expand Down
10 changes: 6 additions & 4 deletions scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ function logCompiling(showCompiling) {

function logTrace(stats, showCompiling) {
if (stats.hasErrors()) {
const [file, loader, ...trace] = stats.toJson('errors-only', { colors: true }).children[0].errors[0].split('\n');
const { moduleName: file, message } = stats.toJson('errors-only', { colors: true }).children[0].errors[0];
const [loader, ...trace] = message.split('\n');
if (loader.indexOf('/nullstack/loaders') === -1) trace.unshift(loader)
const currentTrace = trace.join(' ');
if (lastTrace === currentTrace) return;
Expand Down Expand Up @@ -55,14 +56,14 @@ function start({ input, port }) {
compiler.watch({}, (error, stats) => logTrace(stats, true));
}

function build({ input, output, mode = 'ssr' }) {
function build({ input, output, cache, mode = 'ssr' }) {
const environment = 'production';
const compiler = getCompiler({ environment, input });
const compiler = getCompiler({ environment, input, cache });
console.log(` 🚀️ Building your application in ${mode} mode...`);
compiler.run((error, stats) => {
logTrace(stats, false);
if (stats.hasErrors()) process.exit(1);
require(`../builders/${mode}`)(output);
require(`../builders/${mode}`)({ output, cache });
});
}

Expand All @@ -82,6 +83,7 @@ program
.addOption(new program.Option('-m, --mode <mode>', 'Build production bundles').choices(buildModes))
.option('-i, --input <input>', 'Path to project that will be built')
.option('-o, --output <output>', 'Path to build output folder')
.option('-c, --cache', 'Cache build results in .production folder')
.helpOption('-h, --help', 'Learn more about this command')
.action(build)

Expand Down
28 changes: 28 additions & 0 deletions tests/jest-puppeteer.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// get environment variable
const CI = !!process.env.CI;

const baseOptions = {
server: {
command: 'npm run start',
port: 6969,
launchTimeout: 25000
},
browserContext: 'incognito'
}

const ciPipelineOptions = {
launch: {
executablePath: '/usr/bin/google-chrome-stable',
headless: true,
args: [
'--ignore-certificate-errors',
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-accelerated-2d-canvas',
'--disable-gpu'
]
},
...baseOptions
}

module.exports = CI ? ciPipelineOptions : baseOptions;
7 changes: 7 additions & 0 deletions tests/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const CI = !!process.env.CI;

module.exports = {
preset: "jest-puppeteer",
forceExit: CI,
testTimeout: CI ? 5000 : 20000
}
3 changes: 2 additions & 1 deletion tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
"jest": "^26.6.3",
"nullstack": "*",
"puppeteer": "^5.5.0",
"jest-puppeteer": "^6.0.3",
"webpack-cli": "^3.3.12"
},
"scripts": {
"start": "npx nullstack start --input=./tests --port=6969",
"build": "npx nullstack build --input=./tests --mode=ssr",
"test": "npm run build && jest --testTimeout=20000",
"test": "npm run build && jest",
"script": "node src/scripts/run.js"
},
"dependencies": {
Expand Down
14 changes: 0 additions & 14 deletions tests/src/Application.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
const puppeteer = require('puppeteer');

let browser;
let page;

beforeAll(async () => {
browser = await puppeteer.launch();
page = await browser.newPage();
});

describe('Application', () => {

test('the application is running', async () => {
Expand All @@ -32,8 +22,4 @@ describe('Application', () => {
expect(element).toBeTruthy();
});

});

afterAll(async () => {
browser.close();
});
12 changes: 0 additions & 12 deletions tests/src/ChildComponent.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
const puppeteer = require('puppeteer');

let browser;
let page;

beforeAll(async () => {
browser = await puppeteer.launch();
page = await browser.newPage();
await page.goto('http://localhost:6969/child-component');
});

Expand Down Expand Up @@ -43,9 +36,4 @@ describe('ChildComponent', () => {
expect(element).toBeTruthy();
});


});

afterAll(async () => {
browser.close();
});
11 changes: 0 additions & 11 deletions tests/src/Context.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
const puppeteer = require('puppeteer');

let browser;
let page;

beforeAll(async () => {
browser = await puppeteer.launch();
page = await browser.newPage();
await page.goto('http://localhost:6969/context');
});

Expand Down Expand Up @@ -36,8 +29,4 @@ describe('Context', () => {
expect(element).toBeTruthy();
});

});

afterAll(async () => {
browser.close();
});
11 changes: 0 additions & 11 deletions tests/src/ContextData.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
const puppeteer = require('puppeteer');

let browser;
let page;

beforeAll(async () => {
browser = await puppeteer.launch();
page = await browser.newPage();
await page.goto('http://localhost:6969/context-data');
});

Expand All @@ -28,8 +21,4 @@ describe('ContextData', () => {
expect(element).toBeTruthy();
});

});

afterAll(async () => {
browser.close();
});
11 changes: 0 additions & 11 deletions tests/src/ContextEnvironment.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
const puppeteer = require('puppeteer');

let browser;
let page;

beforeAll(async () => {
browser = await puppeteer.launch();
page = await browser.newPage();
await page.goto('http://localhost:6969/context-environment');
});

Expand Down Expand Up @@ -48,8 +41,4 @@ describe('ContextEnvironment', () => {
expect(element).toBeTruthy();
});

});

afterAll(async () => {
browser.close();
});
12 changes: 0 additions & 12 deletions tests/src/ContextPage.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
const puppeteer = require('puppeteer');

let browser;
let page;

beforeAll(async () => {
browser = await puppeteer.launch();
page = await browser.newPage();
await page.goto('http://localhost:6969/context-page');
});

Expand Down Expand Up @@ -95,9 +88,4 @@ describe('ContextPage', () => {
expect(element).toBeTruthy();
});


});

afterAll(async () => {
browser.close();
});
Loading