mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Add dev server script
This commit is contained in:
41
tests/server.js
Normal file
41
tests/server.js
Normal file
@ -0,0 +1,41 @@
|
||||
const express = require('express');
|
||||
const cors = require('cors');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const webpack = require('webpack');
|
||||
const config = require('../webpack.config');
|
||||
const serveIndex = require('serve-index');
|
||||
|
||||
const PORT = 8080;
|
||||
const CORS_PORT = 8081;
|
||||
|
||||
const app = express();
|
||||
app.use('/', serveIndex(path.resolve(__dirname, '../'), {icons: true}));
|
||||
app.use('/', express.static(path.resolve(__dirname, '../')));
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server running on port ${PORT}`);
|
||||
});
|
||||
|
||||
const corsApp = express();
|
||||
corsApp.use(cors());
|
||||
corsApp.use('/', express.static(path.resolve(__dirname, '../')));
|
||||
corsApp.listen(CORS_PORT, () => {
|
||||
console.log(`CORS server running on port ${CORS_PORT}`);
|
||||
});
|
||||
|
||||
const compiler = webpack(config);
|
||||
compiler.watch(
|
||||
{
|
||||
aggregateTimeout: 300 // wait so long for more changes
|
||||
},
|
||||
(err, stats) => {
|
||||
console.error(err);
|
||||
|
||||
console.log(
|
||||
stats.toString({
|
||||
chunks: false, // Makes the build much quieter
|
||||
colors: true
|
||||
})
|
||||
);
|
||||
}
|
||||
);
|
@ -117,7 +117,8 @@ const assertPath = (result, expected, desc) => {
|
||||
return testContainer.contentWindow
|
||||
.html2canvas(testContainer.contentWindow.document.documentElement, {
|
||||
removeContainer: true,
|
||||
backgroundColor: '#ffffff'
|
||||
backgroundColor: '#ffffff',
|
||||
...(testContainer.contentWindow.h2cOptions || {})
|
||||
})
|
||||
.then(canvas => {
|
||||
try {
|
||||
@ -388,7 +389,7 @@ const assertPath = (result, expected, desc) => {
|
||||
version: platform.version
|
||||
}
|
||||
}),
|
||||
'http://localhost:8081/screenshot/chunk'
|
||||
'http://localhost:8000/screenshot/chunk'
|
||||
)
|
||||
)
|
||||
);
|
||||
@ -407,7 +408,7 @@ const assertPath = (result, expected, desc) => {
|
||||
version: platform.version
|
||||
}
|
||||
}),
|
||||
'http://localhost:8081/screenshot'
|
||||
'http://localhost:8000/screenshot'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user