@nextsparkjs/core 0.1.0-beta.22 → 0.1.0-beta.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextsparkjs/core",
3
- "version": "0.1.0-beta.22",
3
+ "version": "0.1.0-beta.23",
4
4
  "description": "NextSpark - The complete SaaS framework for Next.js",
5
5
  "license": "MIT",
6
6
  "author": "NextSpark <hello@nextspark.dev>",
@@ -5,17 +5,49 @@
5
5
  * Use it to load plugins, add global hooks, and import commands.
6
6
  */
7
7
 
8
+ // Testing Library for better element queries
9
+ import '@testing-library/cypress/add-commands'
10
+
11
+ // Import @cypress/grep for test filtering by tags
12
+ import registerCypressGrep from '@cypress/grep'
13
+ registerCypressGrep()
14
+
8
15
  // Import custom commands
9
16
  import './commands'
10
17
 
11
18
  // Import documentation commands (optional - for demo videos)
19
+ // Requires cypress-slow-down: pnpm add -D cypress-slow-down
12
20
  // import './doc-commands'
13
21
 
14
- // Disable uncaught exception handling to prevent test failures
15
- // from application errors that don't affect test assertions
22
+ // Global error handling
16
23
  Cypress.on('uncaught:exception', (err) => {
17
- // Returning false here prevents Cypress from failing the test
18
- // You may want to be more selective about which errors to ignore
24
+ // Ignore React hydration errors
25
+ if (err.message.includes('Hydration')) {
26
+ return false
27
+ }
28
+ // Ignore ResizeObserver errors
29
+ if (err.message.includes('ResizeObserver')) {
30
+ return false
31
+ }
32
+ // Log other errors but don't fail tests
19
33
  console.error('Uncaught exception:', err.message)
20
34
  return false
21
35
  })
36
+
37
+ // Global before hook
38
+ beforeEach(() => {
39
+ cy.clearCookies()
40
+ cy.clearLocalStorage()
41
+ })
42
+
43
+ // Type declarations for @cypress/grep
44
+ declare global {
45
+ namespace Cypress {
46
+ interface SuiteConfigOverrides {
47
+ tags?: string | string[]
48
+ }
49
+ interface TestConfigOverrides {
50
+ tags?: string | string[]
51
+ }
52
+ }
53
+ }
@@ -1,13 +1,18 @@
1
1
  /**
2
2
  * Cypress Configuration for Starter Theme
3
3
  *
4
- * This config is theme-specific and used by scripts/cy.mjs.
5
- * Run with: NEXT_PUBLIC_ACTIVE_THEME=starter pnpm cy:open
4
+ * This config is self-contained for npm projects created with `nextspark init`.
5
+ * Run with: pnpm cy:open
6
6
  */
7
7
 
8
8
  import { defineConfig } from 'cypress'
9
9
  import path from 'path'
10
10
  import fs from 'fs'
11
+ import { fileURLToPath } from 'url'
12
+
13
+ // ESM-compatible __dirname
14
+ const __filename = fileURLToPath(import.meta.url)
15
+ const __dirname = path.dirname(__filename)
11
16
 
12
17
  // Paths relative to this config file
13
18
  const themeRoot = path.resolve(__dirname, '..')
@@ -18,24 +23,21 @@ const narrationsOutputDir = path.join(__dirname, 'cypress/videos/narrations')
18
23
  import dotenv from 'dotenv'
19
24
  dotenv.config({ path: path.join(projectRoot, '.env') })
20
25
 
21
- // Server port (from .env or default 5173)
22
- const port = process.env.PORT || 5173
26
+ // Server port (from .env or default 3000)
27
+ const port = process.env.PORT || 3000
23
28
 
24
29
  export default defineConfig({
25
30
  e2e: {
26
31
  // Base URL for the application
27
32
  baseUrl: `http://localhost:${port}`,
28
33
 
29
- // Spec patterns: core tests + theme tests
34
+ // Spec patterns: theme tests only
30
35
  specPattern: [
31
- // Core tests (always included)
32
- path.join(projectRoot, 'core/tests/cypress/e2e/core/**/*.cy.{js,ts}'),
33
- // Theme-specific tests
34
36
  path.join(__dirname, 'cypress/e2e/**/*.cy.{js,ts}'),
35
37
  ],
36
38
 
37
- // Support file (shared across themes)
38
- supportFile: path.join(projectRoot, 'core/tests/cypress/support/e2e.ts'),
39
+ // Support file (theme-local)
40
+ supportFile: path.join(__dirname, 'cypress/support/e2e.ts'),
39
41
 
40
42
  // Fixtures folder (theme-specific)
41
43
  fixturesFolder: path.join(__dirname, 'cypress/fixtures'),
@@ -96,15 +98,16 @@ export default defineConfig({
96
98
  grepOmitFiltered: true,
97
99
  },
98
100
 
99
- setupNodeEvents(on, config) {
101
+ async setupNodeEvents(on, config) {
100
102
  // Allure plugin setup (allure-cypress)
101
- const { allureCypress } = require('allure-cypress/reporter')
103
+ const { allureCypress } = await import('allure-cypress/reporter')
102
104
  allureCypress(on, config, {
103
105
  resultsDir: path.join(__dirname, 'cypress/allure-results'),
104
106
  })
105
107
 
106
108
  // @cypress/grep plugin for test filtering by tags
107
- require('@cypress/grep/src/plugin')(config)
109
+ const grepPlugin = await import('@cypress/grep/src/plugin.js')
110
+ ;(grepPlugin.default || grepPlugin)(config)
108
111
 
109
112
  // Documentation video tasks
110
113
  on('task', {
@@ -127,7 +130,7 @@ export default defineConfig({
127
130
  const filepath = path.join(narrationsOutputDir, filename)
128
131
 
129
132
  fs.writeFileSync(filepath, JSON.stringify(narrations, null, 2))
130
- console.log(`Narrations saved to: ${filepath}`)
133
+ console.log(`📝 Narrations saved to: ${filepath}`)
131
134
 
132
135
  return null
133
136
  },
@@ -136,7 +139,7 @@ export default defineConfig({
136
139
  * Add narration entry (called per narration)
137
140
  */
138
141
  addNarration(narration: unknown) {
139
- console.log('Narration:', narration)
142
+ console.log('🎙️ Narration:', narration)
140
143
  return null
141
144
  },
142
145
  })