-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcypress.config.js
More file actions
50 lines (45 loc) · 1.67 KB
/
cypress.config.js
File metadata and controls
50 lines (45 loc) · 1.67 KB
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
const { defineConfig } = require('cypress')
const { createClient } = require('@supabase/supabase-js')
const credentials = require('./cypress/fixtures/supabaseCredentials.json') // Güvenlik: Supabase bağlantı bilgilerini dosyadan alıyoruz.
module.exports = defineConfig({
e2e: {
baseUrl: 'http://localhost:5173',
setupNodeEvents(on, config) {
// "cleanupTestData" görevini tanımlıyoruz.
on('task', {
cleanupTestData() {
// Supabase bağlantı bilgilerini önce ortam değişkenlerinden, yoksa dosyadan alıyoruz.
const supabaseUrl = process.env.SUPABASE_URL || credentials.url
const supabaseAnonKey = process.env.SUPABASE_ANON_KEY || credentials.anonKey
if (!supabaseUrl || !supabaseAnonKey) {
throw new Error('Test veritabanı bağlantı bilgileri eksik!')
}
// Supabase client'ını oluşturuyoruz.
const supabase = createClient(supabaseUrl, supabaseAnonKey)
// "test_data" sütunu true olan kayıtları temizliyoruz.
return Promise.all([
supabase.from('categories').delete().eq('test_data', true),
supabase.from('sub_categories').delete().eq('test_data', true)
])
.then(() => {
return null // Görevi başarıyla tamamladık.
})
.catch((err) => {
console.error('Test cleanup hatası:', err)
throw err
})
}
})
return config
},
},
component: {
devServer: {
framework: 'react',
bundler: 'vite'
},
specPattern: 'src/**/*.cy.{js,jsx,ts,tsx}'
},
viewportWidth: 1280,
viewportHeight: 720
})