WIP (this commit will be re-written): update use native Node ESM for server code, update config files to specifically use .cjs (those tools don't support Node ESM files yet), use a single eslintrc file, all test code uses ESM import/export syntax instead of require (WIP)

This commit is contained in:
Joe Pea
2020-11-16 00:15:14 -08:00
parent c354bceb92
commit d72dd287c8
62 changed files with 1052 additions and 616 deletions
-3
View File
@@ -1,3 +0,0 @@
module.exports = {
extends: ['plugin:jest-playwright/recommended'],
};
+9 -11
View File
@@ -1,10 +1,8 @@
// Modules, constants, and variables
// -----------------------------------------------------------------------------
const docsifyInit = require('../helpers/docsify-init');
import docsifyInit from '../helpers/docsify-init';
// Suite
// -----------------------------------------------------------------------------
describe(`Example Tests`, function() {
describe(`Example Tests`, function () {
// Tests
// ---------------------------------------------------------------------------
test('dom manipulation', async () => {
@@ -17,7 +15,7 @@ describe(`Example Tests`, function() {
// Add class to <body> element and test
// https://playwright.dev/#path=docs%2Fapi.md&q=pageevalselector-pagefunction-arg
await page.$eval('body', elm => elm.classList.add('foo'));
await page.$eval('body', (elm) => elm.classList.add('foo'));
expect(await page.getAttribute('body', 'class')).toEqual('foo');
// Test using helper methods from expect-playright (via jest-playwright)
@@ -58,7 +56,7 @@ describe(`Example Tests`, function() {
// Get result of script executed in browser context
// https://playwright.dev/#path=docs%2Fapi.md&q=pageevaluatepagefunction-arg
const scriptResult = await page.evaluate(
numbers => {
(numbers) => {
const result = numbers.reduce(
(accumulator, currentValue) => accumulator + currentValue
);
@@ -106,7 +104,7 @@ describe(`Example Tests`, function() {
// Add docsify target element
// https://playwright.dev/#path=docs%2Fapi.md&q=pageevalselector-pagefunction-arg
await page.$eval('body', elm => {
await page.$eval('body', (elm) => {
elm.innerHTML = '<div id="app"></div>';
});
@@ -240,9 +238,9 @@ describe(`Example Tests`, function() {
// Verify docsifyInitConfig.script was added to the DOM
expect(
await page.evaluate(scriptText => {
await page.evaluate((scriptText) => {
return [...document.querySelectorAll('script')].some(
elm => elm.textContent.replace(/\s+/g, '') === scriptText
(elm) => elm.textContent.replace(/\s+/g, '') === scriptText
);
}, docsifyInitConfig.script.replace(/\s+/g, ''))
).toBe(true);
@@ -262,9 +260,9 @@ describe(`Example Tests`, function() {
// Verify docsifyInitConfig.style was added to the DOM
expect(
await page.evaluate(styleText => {
await page.evaluate((styleText) => {
return [...document.querySelectorAll('style')].some(
elm => elm.textContent.replace(/\s+/g, '') === styleText
(elm) => elm.textContent.replace(/\s+/g, '') === styleText
);
}, docsifyInitConfig.style.replace(/\s+/g, ''))
).toBe(true);
+2 -2
View File
@@ -1,8 +1,8 @@
const docsifyInit = require('../helpers/docsify-init');
import docsifyInit from '../helpers/docsify-init';
// Suite
// -----------------------------------------------------------------------------
describe('Search Plugin Tests', function() {
describe('Search Plugin Tests', function () {
// Tests
// ---------------------------------------------------------------------------
test('search readme', async () => {
+4 -4
View File
@@ -1,6 +1,6 @@
const docsifyInit = require('../helpers/docsify-init');
import docsifyInit from '../helpers/docsify-init';
describe('Vue.js Rendering', function() {
describe('Vue.js Rendering', function () {
const vueURLs = [
`${NODE_MODULES_URL}/vue2/dist/vue.js`,
`${NODE_MODULES_URL}/vue3/dist/vue.global.js`,
@@ -23,7 +23,7 @@ describe('Vue.js Rendering', function() {
await expect(page).toEqualText('#test', 'test{{ i }}');
});
describe('Basic rendering', function() {
describe('Basic rendering', function () {
for (const vueURL of vueURLs) {
const vueVersion = vueURL.match(/vue(\d+)/)[1]; // vue2|vue3
@@ -52,7 +52,7 @@ describe('Vue.js Rendering', function() {
}
});
describe('Advanced usage', function() {
describe('Advanced usage', function () {
const testData = {
vue2: {
markdown: `