-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathsimplest-project.spec.ts
50 lines (42 loc) · 1.59 KB
/
simplest-project.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { browserFunctions, StylableProjectRunner } from '@stylable/e2e-test-kit';
import { expect } from 'chai';
import { dirname, join } from 'path';
const project = 'simplest-project';
const projectDir = dirname(
require.resolve(`@stylable/webpack-plugin/test/e2e/projects/${project}/webpack.config`),
);
describe(`(${project})`, () => {
const projectRunner = StylableProjectRunner.mochaSetup(
{
projectDir,
launchOptions: {
// headless: false
},
webpackOptions: {
output: { path: join(projectDir, 'dist2') },
},
},
before,
afterEach,
after,
);
it('renders css', async () => {
const { page } = await projectRunner.openInBrowser();
const styleElements = await page.evaluate(browserFunctions.getStyleElementsMetadata);
expect(styleElements).to.eql([{ id: './src/index.st.css', depth: '1' }]);
});
it('css is injected before entry running', async () => {
const { page } = await projectRunner.openInBrowser();
const backgroundColor = await page.evaluate(() => {
return (window as any).backgroundColorAtLoadTime;
});
expect(backgroundColor).to.eql('rgb(255, 0, 0)');
});
it('css is working', async () => {
const { page } = await projectRunner.openInBrowser();
const backgroundColor = await page.evaluate(() => {
return getComputedStyle(document.documentElement).backgroundColor;
});
expect(backgroundColor).to.eql('rgb(255, 0, 0)');
});
});