1
0
Fork 0
mirror of https://github.com/Oreolek/pancakes-or-waffles.git synced 2024-04-30 16:09:31 +03:00

local tests

This commit is contained in:
Laura 2018-01-23 21:17:49 +00:00
parent 39a6bce6d7
commit 39350e104d
10 changed files with 159 additions and 11 deletions

2
.nvmrc
View file

@ -1 +1 @@
8.5
8.4.0

40
bin/run-tests.js Executable file
View file

@ -0,0 +1,40 @@
#!/usr/bin/env node
/*eslint no-console:0 */
require('dotenv').config();
const puppeteer = require('puppeteer');
const path = require('path');
const reporter = require('./tools/reporter.js');
const config = require('../bot.config.js');
const server = require('../express/app.js');
const port = 1337; /*bite me*/
const url = `http://localhost:${port}/test.html`;
const outPath = path.join(__dirname, '..', config.paths.build, config.filenames.base + '.jpg');
// Source: https://github.com/GoogleChrome/puppeteer#usage
const listenForMocha = async () => {
const browser = await puppeteer.launch({
args: ['--no-sandbox']
});
const page = await browser.newPage();
await Promise.all(page.goto(url));
page.on('console', msg => {
console.log(msg);
});
await page.waitFor(2000);
await browser.close();
return log;
};
server.listen(port, ()=>{
reporter.success('Server running');
listenForMocha().then((log)=>{
reporter.success('Tests ran');
process.exit();
}).catch(reporter.error);
});

View file

@ -7,7 +7,7 @@
<body>
</body>
<%if (typeof htmlWebpackPlugin.options.test !== 'undefined') { %>
<script src="node_modules/mocha/mocha.js"></script>
<script src="test/mocha.js"></script>
<script>mocha.setup('bdd');</script>
<script src="test/test.js"></script>
<div id="mocha"></div>

View file

@ -6,7 +6,10 @@ const googleImageSearch = require('./googleImageSearch.js');
const app = express();
app.use(express.static(path.resolve(__dirname, '../build')));
app.use('/test', express.static(path.resolve(__dirname, '../test')));
app.get('/', (req, res, next) => res.sendFile(path.resolve(__dirname, '../build/index.html')));
app.get('/test.html', (req, res, next) => res.sendFile(path.resolve(__dirname, '../build/test.html')));
app.get('/get-image', (req, res, next) =>
googleImageSearch(req.query.query).then(res.json)
);

110
package-lock.json generated
View file

@ -3773,6 +3773,11 @@
"resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz",
"integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8="
},
"browser-stdout": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz",
"integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8="
},
"browserify-aes": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.1.1.tgz",
@ -4444,6 +4449,11 @@
"resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz",
"integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM="
},
"commander": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz",
"integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ=="
},
"commondir": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz",
@ -5038,6 +5048,11 @@
"repeating": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz"
}
},
"diff": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/diff/-/diff-3.3.1.tgz",
"integrity": "sha512-MKPHZDMB0o6yHyDryUOScqZibp914ksXwAMYMTHj6KO8UeKsRYNJD3oNCKjTqZon+V488P7N/HzXF8t7ZR95ww=="
},
"diffie-hellman": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.2.tgz",
@ -6877,6 +6892,11 @@
"version": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg="
},
"growl": {
"version": "1.10.3",
"resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz",
"integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q=="
},
"has": {
"version": "https://registry.npmjs.org/has/-/has-1.0.1.tgz",
"integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=",
@ -6916,6 +6936,11 @@
"minimalistic-assert": "1.0.0"
}
},
"he": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz",
"integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0="
},
"hmac-drbg": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz",
@ -7720,6 +7745,11 @@
"resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz",
"integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE="
},
"json-stringify-safe": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus="
},
"json5": {
"version": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz",
"integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE="
@ -8005,6 +8035,86 @@
}
}
},
"mocha": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-5.0.0.tgz",
"integrity": "sha512-ukB2dF+u4aeJjc6IGtPNnJXfeby5d4ZqySlIBT0OEyva/DrMjVm5HkQxKnHDLKEfEQBsEnwTg9HHhtPHJdTd8w==",
"requires": {
"browser-stdout": "1.3.0",
"commander": "2.11.0",
"debug": "3.1.0",
"diff": "3.3.1",
"escape-string-regexp": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"glob": "7.1.2",
"growl": "1.10.3",
"he": "1.1.1",
"mkdirp": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"supports-color": "4.4.0"
},
"dependencies": {
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
},
"brace-expansion": {
"version": "1.1.8",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz",
"integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=",
"requires": {
"balanced-match": "1.0.0",
"concat-map": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz"
}
},
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"requires": {
"ms": "2.0.0"
}
},
"glob": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"requires": {
"fs.realpath": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"inflight": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"minimatch": "3.0.4",
"once": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"path-is-absolute": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz"
}
},
"has-flag": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz",
"integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE="
},
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"requires": {
"brace-expansion": "1.1.8"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"supports-color": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz",
"integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==",
"requires": {
"has-flag": "2.0.0"
}
}
}
},
"ms": {
"version": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz",
"integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U="

View file

@ -28,9 +28,9 @@
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^0.11.2",
"fs-extra": "^3.0.1",
"mocha-puppeteer": "^0.13.0",
"html-webpack-plugin": "^2.28.0",
"minimist": "^1.2.0",
"mocha": "^5.0.0",
"number-to-text": "^0.3.2",
"pluralize": "^5.0.0",
"postcss-loader": "^2.0.5",
@ -71,6 +71,6 @@
"make-dll": "webpack --config etc/vendor-dll.webpack.config",
"localpost": "npm run webpack && ./bin/screenshot.js && ./bin/upload.js",
"shitpost": "npm run webpack && ./bin/screenshot.js && ./bin/upload-twitter.js",
"test": "mocha-puppeteer ./tests"
"test": "./bin/run-tests.js"
}
}

1
test/mocha.js Symbolic link
View file

@ -0,0 +1 @@
../node_modules/mocha/mocha.js

View file

@ -1 +0,0 @@
<!DOCTYPE html><html><head><meta charset="UTF-8"><title>๐Ÿ‘๐Ÿ‘„๐Ÿ‘โ˜๏ธ</title><link href="../build/app.css" rel="stylesheet"></head><body><script type="text/javascript" src="main.bundle.js"></script><script type="text/javascript" src="../build/promise.js"></script><script type="text/javascript" src="../build/post.js"></script></body><script src="node_modules/mocha/mocha.js"></script><script>mocha.setup('bdd');</script><script src="test/test.js"></script><div id="mocha"></div><link href="test/test.css" rel="stylesheet"><script>mocha.run();</script></html>

View file

@ -1,7 +1,3 @@
const library = require('../src/app.js');
window.Post = library;
describe('Initialization', function() {
it('window.post should exist',function(done){
if(window.Post) {

View file

@ -58,7 +58,6 @@ module.exports = {
},
template: path.join('etc','bot.template.ejs'),
filename: `${config.filenames.base}.html`,
base: `file://${__dirname}/${config.paths.build}/${config.filenames.base}.html`
}),
new HtmlWebpackPlugin({
title: '๐Ÿ‘๐Ÿ‘„๐Ÿ‘โ˜๏ธ',
@ -66,7 +65,7 @@ module.exports = {
collapseWhitespace: true
},
template: path.join('etc','bot.template.ejs'),
filename: path.join('..',config.paths.test,config.filenames.test+'.html'),
filename: path.join('..',config.paths.build,config.filenames.test+'.html'),
test: true,
base: `file://${__dirname}/${config.paths.build}/${config.filenames.base}.html`
}),