MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / loadData

Method loadData

lib/test-server.js:25–43  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23 }
24
25 loadData() {
26 try {
27 const content = fs.readFileSync(this.dbFile, 'utf8')
28 const data = JSON.parse(content)
29 // Update lastModified time when loading data
30 if (fs.existsSync(this.dbFile)) {
31 this.lastModified = fs.statSync(this.dbFile).mtime
32 }
33 console.log('[Data Load] Loaded data from file:', JSON.stringify(data))
34 return data
35 } catch (err) {
36 console.warn(`[Data Load] Could not load data file ${this.dbFile}:`, err.message)
37 console.log('[Data Load] Using fallback default data')
38 return {
39 posts: [{ id: 1, title: 'json-server', author: 'davert' }],
40 user: { name: 'john', password: '123456' },
41 }
42 }
43 }
44
45 reloadData() {
46 console.log('[Reload] Reloading data from file...')

Callers 2

constructorMethod · 0.95
reloadDataMethod · 0.95

Calls 1

logMethod · 0.80

Tested by

no test coverage detected