Chart.js/test/integration/integration-test.cjs
Dan Onoshko ce375a6876
feat: add ESM support (#10525)
* feat: add ESM support

* build: rename UMD bundle

* chore: edit supbackages description

* style: disable es/no-import-meta linter rule

* test: dynamic import in cjs module

* docs: edit integrations page

* docs: review fixes

* chore: remove useless regex in webpack config

* ci: test size-limit only for ESM bundle
2022-08-04 18:43:26 -04:00

47 lines
1.3 KiB
JavaScript

'use strict';
const os = require('os');
const fs = require('fs-extra');
const path = require('path');
const childProcess = require('child_process');
const {describe, it} = require('mocha');
function exec(command, options = {}) {
const output = childProcess.execSync(command, {
encoding: 'utf-8',
...options,
});
return output && output.trimEnd();
}
describe('Integration Tests', () => {
const tmpDir = path.join(os.tmpdir(), 'chart.js-tmp');
fs.rmSync(tmpDir, {recursive: true, force: true});
fs.mkdirSync(tmpDir);
const distDir = path.resolve('./');
const archiveName = exec(`npm --quiet pack ${distDir}`, {cwd: tmpDir});
fs.renameSync(
path.join(tmpDir, archiveName),
path.join(tmpDir, 'package.tgz'),
);
function testOnNodeProject(projectName) {
const projectPath = path.join(__dirname, projectName);
const packageJSONPath = path.join(projectPath, 'package.json');
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, 'utf-8'));
it(packageJSON.description, () => {
const cwd = path.join(tmpDir, projectName);
fs.copySync(projectPath, cwd);
exec('npm --quiet install', {cwd, stdio: 'inherit'});
exec('npm --quiet test', {cwd, stdio: 'inherit'});
}).timeout(5 * 60 * 1000);
}
testOnNodeProject('node');
});