Browse Source

Added ES module browser tests

pull/875/head
Jordan Mele 4 years ago
parent
commit
9341f8e314
  1. 17
      tests/test.js
  2. 21
      tests/tests.esm.html
  3. 22
      tests/tests.html
  4. 22
      tests/tests.umd.html

17
tests/test.js

@ -6,15 +6,22 @@ var childProcess = require('child_process'); @@ -6,15 +6,22 @@ var childProcess = require('child_process');
var server = connect().use(serveStatic(path.join(__dirname, '/..'))).listen(8071, function() {
if (process.argv.indexOf('--mocha-headless-chrome') !== -1) {
childProcess.spawn('node_modules/.bin/mocha-headless-chrome', ['-f', 'http://localhost:8071/tests/tests.html'], {
console.log('Running UMD tests...');
childProcess.spawn('node_modules/.bin/mocha-headless-chrome', ['-f', 'http://localhost:8071/tests/tests.umd.html'], {
stdio: 'inherit'
}).on('exit', function(code) {
server.close();
process.exit(code); // eslint-disable-line no-process-exit
}).on('exit', function() {
console.log('Running ESM tests...');
childProcess.spawn('node_modules/.bin/mocha-headless-chrome', ['-f', 'http://localhost:8071/tests/tests.esm.html'], {
stdio: 'inherit'
}).on('exit', function(code) {
server.close();
process.exit(code); // eslint-disable-line no-process-exit
});
});
} else {
open('http://localhost:8071/tests/tests.html');
open('http://localhost:8071/tests/tests.umd.html');
open('http://localhost:8071/tests/tests.esm.html');
console.log('Serving tests...');
}
});

21
tests/tests.esm.html

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
<html>
<head>
<title>Papa Parse Tests</title>
<meta charset="utf-8">
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="../node_modules/mocha/mocha.js" defer></script>
<script src="../node_modules/chai/chai.js" defer></script>
<script src="../papaparse.js" defer></script>
<script type="module">
mocha.setup('bdd');
mocha.checkLeaks();
</script>
<script src="test-cases.js" id="test-cases" defer></script>
<script type="module">
mocha.run();
</script>
</body>
</html>

22
tests/tests.html

@ -1,22 +0,0 @@ @@ -1,22 +0,0 @@
<html>
<head>
<title>Papa Parse Tests</title>
<meta charset="utf-8">
<script src="../node_modules/mocha/mocha.js"></script>
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
<script src="../papaparse.js"></script>
<script src="../node_modules/chai/chai.js"></script>
<script>mocha.setup('bdd')</script>
<script src="test-cases.js" id="test-cases"></script>
</head>
<body>
<div id="mocha"></div>
<script>
mocha.checkLeaks();
mocha.run();
</script>
</body>
</html>

22
tests/tests.umd.html

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
<html>
<head>
<title>Papa Parse Tests</title>
<meta charset="utf-8">
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="../node_modules/mocha/mocha.js"defer></script>
<script src="../node_modules/chai/chai.js" defer></script>
<script type="module">
import * as Papa from '../papaparse.mjs';
window.Papa = Papa;
mocha.setup('bdd');
mocha.checkLeaks();
</script>
<script src="test-cases.js" id="test-cases" defer></script>
<script type="module">
mocha.run();
</script>
</body>
</html>
Loading…
Cancel
Save