\#3248 add test file

This commit is contained in:
Alexandre Strzelewicz 2017-11-02 16:06:03 +01:00
parent 7591c74f22
commit 56280887b1
6 changed files with 62 additions and 0 deletions

22
test/bash/mjs.sh Normal file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env bash
SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
cd $file_path/mjs
# Activate test only for Node > 9.0.0
node -e "require('semver').gte(process.versions.node, '9.0.0') ? process.exit(0) : process.exit(1)"
[ $? -eq 0 ] || exit 0
$pm2 start --node-args="--experimental-modules" index.mjs -o outech.log -e errech.log
>outech.log
>errech.log
sleep 1
should 'should app be online in fork mode with MJS support' 'online' 1
$pm2 delete all
$pm2 start --node-args="--experimental-modules" -i 2 index.mjs
sleep 1
should 'should app be online in cluster mode with MJS support' 'online' 2

14
test/fixtures/mjs/ecosystem.config.js vendored Normal file
View File

@ -0,0 +1,14 @@
module.exports = {
apps : [
{
name : 'Test es6 modules',
script : 'index.mjs',
node_args : '--experimental-modules'
}
],
};

3
test/fixtures/mjs/index.mjs vendored Normal file
View File

@ -0,0 +1,3 @@
import {test} from './test'
test();

18
test/fixtures/mjs/package.json vendored Normal file
View File

@ -0,0 +1,18 @@
{
"name": "test-es6-pm2",
"version": "1.0.0",
"description": "A simple project to test pm2 es6-modules pm2 support",
"main": "index.mjs",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node --experimental-modules index.mjs"
},
"keywords": [
"es6-modules",
"import",
"export",
"pm2"
],
"author": "vpotseluyko",
"license": "ISC"
}

3
test/fixtures/mjs/test.mjs vendored Normal file
View File

@ -0,0 +1,3 @@
export function test() {
setInterval(() => console.log(`Hello es6 from pm2`), 1000);
}

View File

@ -33,6 +33,8 @@ spec "resurrect test"
# spec "Docker tests"
bash ./test/bash/nvm-node-version.sh
spec "NVM node version setting"
bash ./test/bash/mjs.sh
spec "Test import syntax"
bash ./test/bash/cron-system.sh
spec "Cron system tests"