docsify/test/e2e/index-file.test.js
Joe Pea 62d756c447 refactor: convert to ES Modules and remove traces of CommonJS except in Rollup config because some dependencies are still CommonJS
BREAKING: The new project layout might break in some tooling setups.

We've added an exports field to `package.json` to specify where
statements like `import ... from 'docsify'` will import from, and left
the `main` and `unpkg` fields as-is for backwards compatibility with the
global <script> import method. Most people who use a non-module
`<script>` tag to import Docsify will not notice a difference. Anyone
else who is importing Docsify into a specilized build setup using
`import` statements has a chance of being broken, so we've marked this
as BREAKING.
2023-06-29 19:02:08 -07:00

29 lines
887 B
JavaScript

import docsifyInit from '../helpers/docsify-init.js';
import { test, expect } from './fixtures/docsify-init-fixture.js';
test.describe('Index file hosting', () => {
const sharedOptions = {
config: {
basePath: '/docs/index.html#/',
},
testURL: '/docs/index.html#/',
};
test('should serve from index file', async ({ page }) => {
await docsifyInit(sharedOptions);
await expect(page.locator('#main')).toContainText(
'A magical documentation site generator'
);
expect(page.url()).toMatch(/index\.html#\/$/);
});
test('should use index file links in sidebar from index file hosting', async ({
page,
}) => {
await docsifyInit(sharedOptions);
await page.click('a[href="#/quickstart"]');
await expect(page.locator('#main')).toContainText('Quick start');
expect(page.url()).toMatch(/index\.html#\/quickstart$/);
});
});