|
| 1 | +import { existsSync } from 'node:fs'; |
| 2 | +import { join } from 'node:path'; |
| 3 | +import { rspackOnlyTest } from '@e2e/helper'; |
| 4 | +import { expect } from '@playwright/test'; |
| 5 | +import { createAndValidate } from './helper'; |
| 6 | + |
| 7 | +rspackOnlyTest('should create vanilla project as expected', async () => { |
| 8 | + createAndValidate(__dirname, 'vanilla'); |
| 9 | +}); |
| 10 | + |
| 11 | +rspackOnlyTest('should create vanilla-ts project as expected', async () => { |
| 12 | + createAndValidate(__dirname, 'vanilla-ts'); |
| 13 | +}); |
| 14 | + |
| 15 | +rspackOnlyTest('should create react project as expected', async () => { |
| 16 | + const { pkgJson } = createAndValidate(__dirname, 'react'); |
| 17 | + expect(pkgJson.dependencies.react).toBeTruthy(); |
| 18 | + expect(pkgJson.dependencies['react-dom']).toBeTruthy(); |
| 19 | + expect(pkgJson.devDependencies['@rsbuild/plugin-react']).toBeTruthy(); |
| 20 | +}); |
| 21 | + |
| 22 | +rspackOnlyTest('should create react-ts project as expected', async () => { |
| 23 | + const { pkgJson } = createAndValidate(__dirname, 'react-ts'); |
| 24 | + expect(pkgJson.dependencies.react).toBeTruthy(); |
| 25 | + expect(pkgJson.dependencies['react-dom']).toBeTruthy(); |
| 26 | + expect(pkgJson.devDependencies['@rsbuild/plugin-react']).toBeTruthy(); |
| 27 | +}); |
| 28 | + |
| 29 | +rspackOnlyTest('should create preact project as expected', async () => { |
| 30 | + const { pkgJson } = createAndValidate(__dirname, 'preact'); |
| 31 | + expect(pkgJson.dependencies.preact).toBeTruthy(); |
| 32 | + expect(pkgJson.devDependencies['@rsbuild/plugin-preact']).toBeTruthy(); |
| 33 | +}); |
| 34 | + |
| 35 | +rspackOnlyTest('should create preact-ts project as expected', async () => { |
| 36 | + const { pkgJson } = createAndValidate(__dirname, 'preact-ts'); |
| 37 | + expect(pkgJson.dependencies.preact).toBeTruthy(); |
| 38 | + expect(pkgJson.devDependencies['@rsbuild/plugin-preact']).toBeTruthy(); |
| 39 | +}); |
| 40 | + |
| 41 | +rspackOnlyTest('should create vue3 project as expected', async () => { |
| 42 | + const { pkgJson } = createAndValidate(__dirname, 'vue3'); |
| 43 | + expect(pkgJson.dependencies.vue).toBeTruthy(); |
| 44 | + expect(pkgJson.devDependencies['@rsbuild/plugin-vue']).toBeTruthy(); |
| 45 | +}); |
| 46 | + |
| 47 | +rspackOnlyTest('should create vue3-ts project as expected', async () => { |
| 48 | + const { pkgJson } = createAndValidate(__dirname, 'vue3-ts'); |
| 49 | + expect(pkgJson.dependencies.vue).toBeTruthy(); |
| 50 | + expect(pkgJson.devDependencies['@rsbuild/plugin-vue']).toBeTruthy(); |
| 51 | +}); |
| 52 | + |
| 53 | +rspackOnlyTest('should create vue2 project as expected', async () => { |
| 54 | + const { pkgJson } = createAndValidate(__dirname, 'vue2'); |
| 55 | + expect(pkgJson.dependencies.vue).toBeTruthy(); |
| 56 | + expect(pkgJson.devDependencies['@rsbuild/plugin-vue2']).toBeTruthy(); |
| 57 | +}); |
| 58 | + |
| 59 | +rspackOnlyTest('should create vue2-ts project as expected', async () => { |
| 60 | + const { pkgJson } = createAndValidate(__dirname, 'vue2-ts'); |
| 61 | + expect(pkgJson.dependencies.vue).toBeTruthy(); |
| 62 | + expect(pkgJson.devDependencies['@rsbuild/plugin-vue2']).toBeTruthy(); |
| 63 | +}); |
| 64 | + |
| 65 | +rspackOnlyTest('should create lit project as expected', async () => { |
| 66 | + const { pkgJson } = createAndValidate(__dirname, 'lit'); |
| 67 | + expect(pkgJson.dependencies.lit).toBeTruthy(); |
| 68 | +}); |
| 69 | + |
| 70 | +rspackOnlyTest('should create lit-ts project as expected', async () => { |
| 71 | + const { pkgJson } = createAndValidate(__dirname, 'lit-ts'); |
| 72 | + expect(pkgJson.dependencies.lit).toBeTruthy(); |
| 73 | +}); |
| 74 | + |
| 75 | +rspackOnlyTest('should create solid project as expected', async () => { |
| 76 | + const { pkgJson } = createAndValidate(__dirname, 'solid'); |
| 77 | + expect(pkgJson.dependencies['solid-js']).toBeTruthy(); |
| 78 | + expect(pkgJson.devDependencies['@rsbuild/plugin-solid']).toBeTruthy(); |
| 79 | +}); |
| 80 | + |
| 81 | +rspackOnlyTest('should create solid-ts project as expected', async () => { |
| 82 | + const { pkgJson } = createAndValidate(__dirname, 'solid-ts'); |
| 83 | + expect(pkgJson.dependencies['solid-js']).toBeTruthy(); |
| 84 | + expect(pkgJson.devDependencies['@rsbuild/plugin-solid']).toBeTruthy(); |
| 85 | +}); |
| 86 | + |
| 87 | +rspackOnlyTest('should create svelte project as expected', async () => { |
| 88 | + const { pkgJson } = createAndValidate(__dirname, 'svelte'); |
| 89 | + expect(pkgJson.dependencies.svelte).toBeTruthy(); |
| 90 | + expect(pkgJson.devDependencies['@rsbuild/plugin-svelte']).toBeTruthy(); |
| 91 | +}); |
| 92 | + |
| 93 | +rspackOnlyTest('should create svelte-ts project as expected', async () => { |
| 94 | + const { pkgJson } = createAndValidate(__dirname, 'svelte-ts'); |
| 95 | + expect(pkgJson.dependencies.svelte).toBeTruthy(); |
| 96 | + expect(pkgJson.devDependencies['@rsbuild/plugin-svelte']).toBeTruthy(); |
| 97 | +}); |
| 98 | + |
| 99 | +rspackOnlyTest('should allow to create project in sub dir', async () => { |
| 100 | + createAndValidate(__dirname, 'vanilla', { |
| 101 | + name: 'test-temp-dir/rsbuild-project', |
| 102 | + }); |
| 103 | +}); |
| 104 | + |
| 105 | +rspackOnlyTest('should allow to create project in relative dir', async () => { |
| 106 | + createAndValidate(__dirname, 'vanilla', { |
| 107 | + name: './test-temp-relative-dir', |
| 108 | + }); |
| 109 | +}); |
| 110 | + |
| 111 | +rspackOnlyTest('should create project with eslint as expected', async () => { |
| 112 | + const { dir, pkgJson, clean } = createAndValidate(__dirname, 'vanilla', { |
| 113 | + name: 'test-temp-eslint', |
| 114 | + tools: ['eslint'], |
| 115 | + clean: false, |
| 116 | + }); |
| 117 | + expect(pkgJson.devDependencies.eslint).toBeTruthy(); |
| 118 | + expect(existsSync(join(dir, 'eslint.config.mjs'))).toBeTruthy(); |
| 119 | + clean(); |
| 120 | +}); |
| 121 | + |
| 122 | +rspackOnlyTest('should create project with prettier as expected', async () => { |
| 123 | + const { dir, pkgJson, clean } = createAndValidate(__dirname, 'vanilla', { |
| 124 | + name: 'test-temp-prettier', |
| 125 | + tools: ['prettier'], |
| 126 | + clean: false, |
| 127 | + }); |
| 128 | + expect(pkgJson.devDependencies.prettier).toBeTruthy(); |
| 129 | + expect(existsSync(join(dir, '.prettierrc'))).toBeTruthy(); |
| 130 | + clean(); |
| 131 | +}); |
| 132 | + |
| 133 | +rspackOnlyTest( |
| 134 | + 'should create project with eslint and prettier as expected', |
| 135 | + async () => { |
| 136 | + const { dir, pkgJson, clean } = createAndValidate(__dirname, 'vanilla', { |
| 137 | + name: 'test-temp-eslint-prettier', |
| 138 | + tools: ['eslint', 'prettier'], |
| 139 | + clean: false, |
| 140 | + }); |
| 141 | + expect(pkgJson.devDependencies.eslint).toBeTruthy(); |
| 142 | + expect(pkgJson.devDependencies.prettier).toBeTruthy(); |
| 143 | + expect(existsSync(join(dir, '.prettierrc'))).toBeTruthy(); |
| 144 | + expect(existsSync(join(dir, 'eslint.config.mjs'))).toBeTruthy(); |
| 145 | + clean(); |
| 146 | + }, |
| 147 | +); |
| 148 | + |
| 149 | +rspackOnlyTest('should create project with biome as expected', async () => { |
| 150 | + const { dir, pkgJson, clean } = createAndValidate(__dirname, 'vanilla', { |
| 151 | + name: 'test-temp-eslint', |
| 152 | + tools: ['biome'], |
| 153 | + clean: false, |
| 154 | + }); |
| 155 | + expect(pkgJson.devDependencies['@biomejs/biome']).toBeTruthy(); |
| 156 | + expect(existsSync(join(dir, 'biome.json'))).toBeTruthy(); |
| 157 | + clean(); |
| 158 | +}); |
0 commit comments