diff --git a/.commitlintrc.js b/.commitlintrc.js index 84dcb122a..f9822fcfe 100644 --- a/.commitlintrc.js +++ b/.commitlintrc.js @@ -1,3 +1,2 @@ -module.exports = { - extends: ['@commitlint/config-conventional'], -}; +const Configuration = { extends: ['@commitlint/config-conventional'] }; +export default Configuration; diff --git a/apis/snapshooter/package.json b/apis/snapshooter/package.json index c83c087ca..cfff2450a 100644 --- a/apis/snapshooter/package.json +++ b/apis/snapshooter/package.json @@ -22,7 +22,7 @@ "client.js" ], "scripts": { - "build": "cross-env NODE_ENV=production rollup --config ./rollup.config.js", + "build": "cross-env NODE_ENV=production rollup --bundleConfigAsCjs --config ./rollup.config.js", "prepublishOnly": "rm -rf dist && yarn run build" } -} +} \ No newline at end of file diff --git a/apis/stardust/package.json b/apis/stardust/package.json index 6a3fc629a..701a6a251 100644 --- a/apis/stardust/package.json +++ b/apis/stardust/package.json @@ -30,9 +30,9 @@ "types/index.d.ts" ], "scripts": { - "build": "cross-env NODE_ENV=production rollup --config ../../rollup.config.js", - "build:dev": "rollup --config ../../rollup.config.js", - "build:watch": "rollup --config ../../rollup.config.js -w", + "build": "cross-env NODE_ENV=production rollup --bundleConfigAsCjs --config ../../rollup.config.js", + "build:dev": "rollup --bundleConfigAsCjs --config ../../rollup.config.js", + "build:watch": "rollup --bundleConfigAsCjs --config ../../rollup.config.js -w", "prepublishOnly": "rm -rf dist && yarn run build", "spec:stardust": "sy from-jsdoc -c ./api-spec/spec.conf.js", "spec:listbox": "sy from-jsdoc -c ./api-spec/listbox-spec.conf.js", @@ -67,4 +67,4 @@ "regenerator-runtime": "0.14.1", "semver": "7.6.3" } -} +} \ No newline at end of file diff --git a/apis/test-utils/package.json b/apis/test-utils/package.json index 5970ca166..8f264ea50 100644 --- a/apis/test-utils/package.json +++ b/apis/test-utils/package.json @@ -19,12 +19,12 @@ "dist" ], "scripts": { - "build": "cross-env NODE_ENV=production rollup --config ../../rollup.config.js", - "build:dev": "rollup --config ../../rollup.config.js", - "build:watch": "rollup --config ../../rollup.config.js -w", + "build": "cross-env NODE_ENV=production rollup --bundleConfigAsCjs --config ../../rollup.config.js", + "build:dev": "rollup --bundleConfigAsCjs --config ../../rollup.config.js", + "build:watch": "rollup --bundleConfigAsCjs --config ../../rollup.config.js -w", "prepublishOnly": "rm -rf dist && yarn run build" }, "peerDependencies": { "@nebula.js/stardust": ">=5.0.0" } -} +} \ No newline at end of file diff --git a/aw.config.js b/aw.config.cjs similarity index 100% rename from aw.config.js rename to aw.config.cjs diff --git a/babel.config.js b/babel.config.cjs similarity index 100% rename from babel.config.js rename to babel.config.cjs diff --git a/jest.config.js b/jest.config.js index 250fe3f5c..c84cc0c8e 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,4 +1,4 @@ -module.exports = { +const config = { verbose: true, clearMocks: true, testEnvironment: 'jest-environment-jsdom', @@ -59,3 +59,5 @@ module.exports = { 'd3-color': '/node_modules/d3-color/dist/d3-color.min.js', }, }; + +export default config; diff --git a/package.json b/package.json index 9c5ec4c97..e6691b263 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "private": true, "description": "", + "type": "module", "scripts": { "build": "yarn run locale:generate && cross-env NODE_ENV=production FORCE_COLOR=1 lerna run build --stream", "build:dev": "yarn run locale:generate && cross-env NODE_ENV=development FORCE_COLOR=1 lerna run build --stream", @@ -8,10 +9,10 @@ "install:codesandbox": "yarn --ignore-engines", "build:watch": "FORCE_COLOR=1 lerna run build:watch --stream --concurrency 99 --no-sort", "format": "prettier --write '**/**/*' --ignore-unknown", - "locale:verify": "node tools/verify-translations.js", + "locale:verify": "node tools/verify-translations.cjs", "locale:generate": "node apis/locale/scripts/generate-all.mjs", "lint": "eslint packages apis commands --ext .js,.jsx", - "lint:check": "eslint --print-config ./aw.config.js | eslint-config-prettier-check", + "lint:check": "eslint --print-config ./aw.config.cjs | eslint-config-prettier-check", "spec": "lerna run spec --stream --concurrency 99 && lerna run ts --stream --concurrency 99 ", "mashup": "node scripts/start-mashup.js", "test": "yarn run test:unit", @@ -19,10 +20,10 @@ "test:update": "jest --maxWorkers=2 -u", "test:watch": "jest --watch", "test:coverage": "jest --coverage", - "test:mashup": "aw puppet -c aw.config.js --testExt '*.int.js' --glob 'test/mashup/**/*.int.js'", + "test:mashup": "aw puppet -c aw.config.cjs --testExt '*.int.js' --glob 'test/mashup/**/*.int.js'", "test:rendering": "playwright test --config=./test/rendering/playwright.config.rendering.js --quiet", - "test:integration": "aw puppet -c aw.config.js --testExt '*.int.js' --glob 'test/integration/**/*.int.js'", - "test:component": "aw puppet -c aw.config.js --testExt '*.comp.js' --glob 'test/component/**/*.comp.js'", + "test:integration": "aw puppet -c aw.config.cjs --testExt '*.int.js' --glob 'test/integration/**/*.int.js'", + "test:component": "aw puppet -c aw.config.cjs --testExt '*.comp.js' --glob 'test/component/**/*.comp.js'", "prepare": "husky install" }, "repository": { diff --git a/rollup.config.js b/rollup.config.js index 9925f84f8..b073b7407 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -8,7 +8,7 @@ const { nodeResolve } = require('@rollup/plugin-node-resolve'); const replace = require('@rollup/plugin-replace'); const terser = require('@rollup/plugin-terser'); -const localeStringValidator = require('./tools/locale-string-validator'); +const localeStringValidator = require('./tools/locale-string-validator.cjs'); const cwd = process.cwd(); const pkg = require(path.join(cwd, 'package.json')); // eslint-disable-line diff --git a/test/component/barchart/barchart.comp.js b/test/component/barchart/barchart.comp.cjs similarity index 100% rename from test/component/barchart/barchart.comp.js rename to test/component/barchart/barchart.comp.cjs diff --git a/test/component/hooks/hooks.comp.js b/test/component/hooks/hooks.comp.cjs similarity index 100% rename from test/component/hooks/hooks.comp.js rename to test/component/hooks/hooks.comp.cjs diff --git a/test/component/object/sn.comp.js b/test/component/object/sn.comp.cjs similarity index 100% rename from test/component/object/sn.comp.js rename to test/component/object/sn.comp.cjs diff --git a/test/integration/table/table.int.js b/test/integration/table/table.int.cjs similarity index 100% rename from test/integration/table/table.int.js rename to test/integration/table/table.int.cjs diff --git a/test/mashup/listbox/listbox.int.js b/test/mashup/listbox/listbox.int.cjs similarity index 100% rename from test/mashup/listbox/listbox.int.js rename to test/mashup/listbox/listbox.int.cjs diff --git a/test/mashup/setup.int.js b/test/mashup/setup.int.cjs similarity index 100% rename from test/mashup/setup.int.js rename to test/mashup/setup.int.cjs diff --git a/test/mashup/snaps/snapper.int.js b/test/mashup/snaps/snapper.int.cjs similarity index 100% rename from test/mashup/snaps/snapper.int.js rename to test/mashup/snaps/snapper.int.cjs diff --git a/test/mashup/visualize/life.int.js b/test/mashup/visualize/life.int.cjs similarity index 100% rename from test/mashup/visualize/life.int.js rename to test/mashup/visualize/life.int.cjs diff --git a/test/rendering/listbox/listbox-keyboard-nav.spec.js b/test/rendering/listbox/listbox-keyboard-nav.spec.js index 57eaa3b20..6bef582bc 100644 --- a/test/rendering/listbox/listbox-keyboard-nav.spec.js +++ b/test/rendering/listbox/listbox-keyboard-nav.spec.js @@ -1,8 +1,7 @@ /* eslint-disable no-undef */ import { test, expect } from '@playwright/test'; - -const getPage = require('../setup'); -const startServer = require('../server'); +import getPage from '../setup'; +import startServer from '../server'; test.describe('keyboard navigation', () => { const filePrefix = 'listbox-focus'; diff --git a/test/rendering/listbox/listbox.spec.js b/test/rendering/listbox/listbox.spec.js index eea68358e..66b941a6b 100644 --- a/test/rendering/listbox/listbox.spec.js +++ b/test/rendering/listbox/listbox.spec.js @@ -1,22 +1,19 @@ import { test, expect } from '@playwright/test'; import { act } from '@testing-library/react'; import fs from 'fs'; -import path from 'path'; +import getPage from '../setup'; +import startServer, { getPaths } from '../server'; +import { execSequence } from '../testUtils'; -const getPage = require('../setup'); -const startServer = require('../server'); -const { execSequence } = require('../testUtils'); +const paths = getPaths('listbox/__fixtures__'); -const paths = path.join(__dirname, '__fixtures__'); - -function shouldIgnoreFile(file) { - // Ignore subpaths +const shouldIgnoreFile = (file) => { const IGNORE_PATTERNS = []; const INCLUDE_PATTERNS = [/\.js/]; const ignore = IGNORE_PATTERNS.some((P) => file.search(P) > -1) || INCLUDE_PATTERNS.some((P) => file.search(P) === -1); return ignore; -} +}; test.describe('listbox mashup rendering test', () => { const object = '[data-type="listbox"]'; @@ -31,7 +28,7 @@ test.describe('listbox mashup rendering test', () => { test.use({ viewport: { width: 300, height: 500 } }); test.beforeEach(async () => { - ({ url, destroy: destroyServer } = await startServer(8050)); + ({ url, destroy: destroyServer } = await startServer(8049)); ({ page, destroy: destroyBrowser } = await getPage()); }); @@ -93,7 +90,6 @@ test.describe('listbox mashup rendering test', () => { await search.click(); await search.fill('B'); - // Note that since we don't have a backend providing search results, we can't test highlighting and selected (green) rows. const selector = await page.locator(listboxSelector); const image = await selector.screenshot({ caret: 'hide' }); return expect(image).toMatchSnapshot(FILE_NAME); @@ -109,7 +105,6 @@ test.describe('listbox mashup rendering test', () => { await search.click(); await search.fill('B'); - // Note that since we don't have a backend providing search results, we can't test highlighting and selected (green) rows. const selector = await page.locator(listboxSelector); const image = await selector.screenshot({ caret: 'hide' }); return expect(image).toMatchSnapshot(FILE_NAME); @@ -120,7 +115,6 @@ test.describe('listbox mashup rendering test', () => { await page.goto(`${url}/listbox/listbox.html?scenario=noToolbar`, { waitUntil: 'networkidle' }); - // Note that since we don't have a backend providing search results, we can't test highlighting and selected (green) rows. const selector = await page.locator(listboxSelector); const image = await selector.screenshot({ caret: 'hide' }); return expect(image).toMatchSnapshot(FILE_NAME); @@ -137,7 +131,6 @@ test.describe('listbox mashup rendering test', () => { }); await page.waitForSelector(toolbarPopoverSelector); - // Wait for animation await new Promise((resolve) => { setTimeout(() => { resolve(); diff --git a/test/rendering/playwright.config.rendering.js b/test/rendering/playwright.config.rendering.js index 71025422b..53e31fa95 100644 --- a/test/rendering/playwright.config.rendering.js +++ b/test/rendering/playwright.config.rendering.js @@ -1,4 +1,6 @@ -const config = { +import { defineConfig } from '@playwright/test'; + +export default defineConfig({ reporter: [ ['dot'], ['html', { outputFolder: './reports/html' }], @@ -11,7 +13,7 @@ const config = { toMatchSnapshot: { threshold: 0.00025 }, timeout: 30000, }, - workers: process.env.CI ? 1 : undefined, + workers: 1, use: { browserName: 'chromium', actionTimeout: 30000, @@ -21,6 +23,4 @@ const config = { video: 'retain-on-failure', screenshot: 'only-on-failure', }, -}; - -module.exports = config; +}); diff --git a/test/rendering/server.js b/test/rendering/server.js index 2a45b8ef3..45b80d4d9 100644 --- a/test/rendering/server.js +++ b/test/rendering/server.js @@ -1,13 +1,17 @@ -const express = require('express'); -const path = require('path'); +import express from 'express'; +import path, { dirname } from 'path'; +import { fileURLToPath } from 'url'; -async function startServer(port) { +const FN = fileURLToPath(import.meta.url); +const DN = dirname(FN); + +export default async function startServer(port) { const app = express(); // const port = 8050; const url = `http://localhost:${port}`; - app.use(express.static(path.resolve(__dirname))); - app.use('/apis', express.static(path.resolve(__dirname, '../../apis'))); - app.use('/node_modules', express.static(path.resolve(__dirname, '../../node_modules'))); + app.use(express.static(path.resolve(DN))); + app.use('/apis', express.static(path.resolve(DN, '../../apis'))); + app.use('/node_modules', express.static(path.resolve(DN, '../../node_modules'))); let server; @@ -28,4 +32,6 @@ async function startServer(port) { }; } -module.exports = startServer; +export function getPaths(dir) { + return path.join(DN, dir); +} diff --git a/test/rendering/setup.js b/test/rendering/setup.js index 44ff57a70..d760ecaad 100644 --- a/test/rendering/setup.js +++ b/test/rendering/setup.js @@ -1,6 +1,6 @@ -const { chromium } = require('@playwright/test'); +import { chromium } from '@playwright/test'; -async function getPage() { +export default async function getPage() { const browser = await chromium.launch(); const page = await browser.newPage(); page.setDefaultNavigationTimeout(30000); @@ -12,5 +12,3 @@ async function getPage() { return { browser, page, destroy }; } - -module.exports = getPage; diff --git a/test/rendering/sheet/sheet.spec.js b/test/rendering/sheet/sheet.spec.js index 960ef41b0..ea9cc4a79 100644 --- a/test/rendering/sheet/sheet.spec.js +++ b/test/rendering/sheet/sheet.spec.js @@ -1,7 +1,6 @@ import { test, expect } from '@playwright/test'; - -const getPage = require('../setup'); -const startServer = require('../server'); +import getPage from '../setup'; +import startServer from '../server'; test.describe('sheet mashup rendering test', () => { const object = '[data-type="sheet"]'; @@ -29,6 +28,7 @@ test.describe('sheet mashup rendering test', () => { const image = await selector.screenshot(); return expect(image).toMatchSnapshot(FILE_NAME); }); + test('sheet bound Less test', async () => { const FILE_NAME = 'sheet_bound_less.png'; diff --git a/test/rendering/testUtils.js b/test/rendering/testUtils.js index e1bc28d92..5b20b3244 100644 --- a/test/rendering/testUtils.js +++ b/test/rendering/testUtils.js @@ -1,7 +1,7 @@ -const path = require('path'); -const jimp = require('jimp'); +import path from 'path'; +import jimp from 'jimp'; -async function looksLike(fileName, capturedPath) { +export async function looksLike(fileName, capturedPath) { const artifactsPath = path.resolve(__dirname, './__artifacts__/'); const storedPath = path.resolve(artifactsPath, 'baseline', fileName); @@ -23,7 +23,7 @@ async function looksLike(fileName, capturedPath) { * @param {function[]} items An array of items (e.g. selectors) that will be sent into the action function, iteratively. * @returns {Promise} Resolves true when done. */ -async function execSequence(items, action) { +export async function execSequence(items, action) { const takeAction = async (index = 0) => { if (index >= items.length) { return true; // done @@ -34,8 +34,3 @@ async function execSequence(items, action) { }; return takeAction(); } - -module.exports = { - execSequence, - looksLike, -}; diff --git a/tools/locale-string-validator.js b/tools/locale-string-validator.cjs similarity index 100% rename from tools/locale-string-validator.js rename to tools/locale-string-validator.cjs diff --git a/tools/verify-translations.js b/tools/verify-translations.cjs similarity index 100% rename from tools/verify-translations.js rename to tools/verify-translations.cjs