Refactor simple JS to be main JS tests

[MAILPOET-2455]
This commit is contained in:
Rostislav Wolny
2019-11-27 11:06:41 +01:00
committed by Jack Kitterhing
parent a6dfab1178
commit 6015a1370d
30 changed files with 29 additions and 16 deletions

View File

@ -178,11 +178,11 @@ jobs:
name: "JS Newsletter Editor Tests"
command: |
mkdir test-results/mocha
./do t:j test-results/mocha/junit.xml
./do t:newsletter-editor test-results/mocha/newsletter_editor_junit.xml
- run:
name: "JS Form Editor Tests"
name: "JS Tests"
command: |
npm test
./do t:j test-results/mocha/junit.xml
- store_test_results:
path: test-results/mocha
- store_artifacts:

2
.gitignore vendored
View File

@ -15,7 +15,7 @@ npm-debug.log
temp
.idea
mailpoet.zip
tests/javascript/testBundles
tests/javascript_newsletter_editor/testBundles
assets/dist
.vagrant
lang

View File

@ -204,13 +204,13 @@ class RoboFile extends \Robo\Tasks {
return $this->execWithXDebug($command);
}
function testJavascript($xml_output_file = null) {
function testNewsletterEditor($xml_output_file = null) {
$this->compileJs();
$command = join(' ', [
'./node_modules/.bin/mocha',
'-r tests/javascript/mochaTestHelper.js',
'tests/javascript/testBundles/**/*.js',
'-r tests/javascript_newsletter_editor/mochaTestHelper.js',
'tests/javascript_newsletter_editor/testBundles/**/*.js',
]);
if (!empty($xml_output_file)) {
@ -223,6 +223,19 @@ class RoboFile extends \Robo\Tasks {
return $this->_exec($command);
}
function testJavascript($xml_output_file = null) {
$command = './node_modules/.bin/mocha --require @babel/register tests/javascript/**/*.spec.js';
if (!empty($xml_output_file)) {
$command .= sprintf(
' --reporter xunit --reporter-options output="%s"',
$xml_output_file
);
}
return $this->_exec($command);
}
function securityComposer() {
return $this->collectionBuilder()
->taskExec('vendor/bin/security-checker security:check --format=simple')

View File

@ -11,13 +11,13 @@
],
"scripts": {
"lint": "npm run lint6 && npm run lint5 && npm run lint-tests",
"lint6": "eslint -c .eslintrc.es6.json --max-warnings 0 'assets/js/src/**/*.jsx'",
"lint5": "eslint -c .eslintrc.es5.json --ignore-pattern helpscout.js --max-warnings 0 'assets/js/src/**/*.js' 'tests/javascript_form_editor/**/*.js'",
"lint-tests": "eslint -c .eslintrc.tests.json --max-warnings 0 'tests/javascript'",
"lint6": "eslint -c .eslintrc.es6.json --max-warnings 0 'assets/js/src/**/*.jsx' 'tests/javascript/**/*.js'",
"lint5": "eslint -c .eslintrc.es5.json --ignore-pattern helpscout.js --max-warnings 0 'assets/js/src/**/*.js'",
"lint-tests": "eslint -c .eslintrc.tests_newsletter_editor.json --max-warnings 0 'tests/javascript_newsletter_editor'",
"autoprefixer": "postcss assets/dist/css/*.css --use autoprefixer --no-map --replace",
"scss": "node-sass assets/css/src/ --output assets/dist/css/ --output-style compact",
"stylelint": "stylelint --fix",
"test": "mocha --compilers js:@babel/register tests/javascript_form_editor/**/*.spec.js"
"test": "mocha --require @babel/register tests/javascript/**/*.spec.js"
},
"dependencies": {
"@babel/runtime": "^7.4.5",

View File

@ -1,6 +1,6 @@
import { describe, it, beforeEach } from 'mocha';
import { expect } from 'chai';
import reducer from '../../../../assets/js/src/form_editor/store/reducers/toggle_sidebar_panel.jsx';
import reducer from '../../../../../assets/js/src/form_editor/store/reducers/toggle_sidebar_panel.jsx';
describe('Toggle Sidebar Panel Reducer', () => {
let initialState = null;

View File

@ -34,7 +34,7 @@ global.jQuery = jQuery;
global.window.jQuery = jQuery;
testHelpers.loadScript('tests/javascript/testBundles/vendor.js', global.window);
testHelpers.loadScript('tests/javascript_newsletter_editor/testBundles/vendor.js', global.window);
const Handlebars = global.window.Handlebars;
global.Handlebars = global.window.Handlebars;

View File

@ -297,7 +297,7 @@ const migratorConfig = {
}
};
// Test config
// Newsletter Editor Tests Config
const testConfig = {
name: 'test',
entry: {
@ -330,7 +330,7 @@ const testConfig = {
],
},
output: {
path: path.join(__dirname, 'tests/javascript/testBundles'),
path: path.join(__dirname, 'tests/javascript_newsletter_editor/testBundles'),
filename: '[name].js',
},
plugins: [
@ -346,7 +346,7 @@ const testConfig = {
modules: [
'node_modules',
'assets/js/src',
'tests/javascript/newsletter_editor'
'tests/javascript_newsletter_editor/newsletter_editor'
],
alias: {
'sticky-kit': 'vendor/jquery.sticky-kit.js',