I'm not sure why your code doesn't work, according to the docs it's fine.
However, here's a code that works ok :)
var myTextArea = document.getElementById("test1"),
var editor = CodeMirror(function(elt) {
myTextArea.parentNode.replaceChild(elt, myTextArea);
}, {value: myTextArea.innerHTML});
Demo: http://jsfiddle.net/edgarinvillegas/gWZeQ/1/
Cheers, from La Paz, Bolivia